diff --git a/.stats.yml b/.stats.yml index 006b15f4..58526a77 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 47 +configured_endpoints: 48 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt index a4b76c84..b945ef4a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt @@ -13,6 +13,11 @@ import java.util.Objects * Get the account usage information between two dates. Note that the API response includes data * from the start date while excluding data from the end date. In other words, the data covers the * period starting from the specified start date up to, but not including, the end date. + * + * For an agency account, the returned usage is aggregated across the agency and all of its child + * accounts that are billed to it. + * + * The response is cached for 6 hours per account, date range and requested metrics. */ class UsageGetParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/RequestBandwidthEntry.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/RequestBandwidthEntry.kt new file mode 100644 index 00000000..fdadc79a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/RequestBandwidthEntry.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.accounts.usageanalytics + +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 io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class RequestBandwidthEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, mutableMapOf()) + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Returns the raw JSON value of [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RequestBandwidthEntry]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RequestBandwidthEntry]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(requestBandwidthEntry: RequestBandwidthEntry) = apply { + bandwidthBytes = requestBandwidthEntry.bandwidthBytes + requestCount = requestBandwidthEntry.requestCount + additionalProperties = requestBandwidthEntry.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RequestBandwidthEntry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RequestBandwidthEntry = + RequestBandwidthEntry( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RequestBandwidthEntry = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RequestBandwidthEntry && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RequestBandwidthEntry{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsGetParams.kt new file mode 100644 index 00000000..e80867bc --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsGetParams.kt @@ -0,0 +1,246 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.accounts.usageanalytics + +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import java.time.LocalDate +import java.util.Objects + +/** + * **Note:** This API is currently in beta. + * + * Get the account analytics data between two dates. The response covers the period from the start + * date to the end date, both dates inclusive. Both dates are interpreted as UTC calendar days. + * + * The returned data is scoped to the requesting account only. Unlike `/v1/accounts/usage`, an + * agency account's analytics are not aggregated across its child accounts. + * + * The response is cached for 5 minutes per account and date range. Use `generatedAt` to check how + * fresh the returned data is. + */ +class UsageAnalyticsGetParams +private constructor( + private val endDate: LocalDate, + private val startDate: LocalDate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should be + * after the `startDate`. The difference between `startDate` and `endDate` should be less than + * 90 days. + */ + fun endDate(): LocalDate = endDate + + /** + * Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should be + * before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 + * days. + */ + fun startDate(): LocalDate = 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 [UsageAnalyticsGetParams]. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageAnalyticsGetParams]. */ + class Builder internal constructor() { + + private var endDate: LocalDate? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(usageAnalyticsGetParams: UsageAnalyticsGetParams) = apply { + endDate = usageAnalyticsGetParams.endDate + startDate = usageAnalyticsGetParams.startDate + additionalHeaders = usageAnalyticsGetParams.additionalHeaders.toBuilder() + additionalQueryParams = usageAnalyticsGetParams.additionalQueryParams.toBuilder() + } + + /** + * Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It should + * be after the `startDate`. The difference between `startDate` and `endDate` should be less + * than 90 days. + */ + fun endDate(endDate: LocalDate) = apply { this.endDate = endDate } + + /** + * Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day. It + * should be before the `endDate`. The difference between `startDate` and `endDate` should + * be less than 90 days. + */ + fun startDate(startDate: LocalDate) = apply { this.startDate = startDate } + + 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 [UsageAnalyticsGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageAnalyticsGetParams = + UsageAnalyticsGetParams( + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("endDate", endDate.toString()) + put("startDate", startDate.toString()) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageAnalyticsGetParams && + endDate == other.endDate && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(endDate, startDate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UsageAnalyticsGetParams{endDate=$endDate, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsResponse.kt new file mode 100644 index 00000000..3e2b2927 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsResponse.kt @@ -0,0 +1,12236 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.accounts.usageanalytics + +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 io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class UsageAnalyticsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val bandwidthBytes: JsonField, + private val browser: JsonField, + private val cache: JsonField, + private val country: JsonField, + private val device: JsonField, + private val endDate: JsonField, + private val errorReasons: JsonField>, + private val extensions: JsonField>, + private val format: JsonField, + private val generatedAt: JsonField, + private val requestCount: JsonField, + private val startDate: JsonField, + private val statusCodes: JsonField>, + private val top404Assets: JsonField>, + private val topImages: JsonField, + private val topImageTransforms: JsonField, + private val topOtherAssets: JsonField, + private val topReferrers: JsonField, + private val topUserAgents: JsonField, + private val topVideos: JsonField, + private val topVideoTransforms: JsonField, + private val urlEndpoints: JsonField, + private val videoProcessing: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("browser") @ExcludeMissing browser: JsonField = JsonMissing.of(), + @JsonProperty("cache") @ExcludeMissing cache: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("device") @ExcludeMissing device: JsonField = JsonMissing.of(), + @JsonProperty("endDate") @ExcludeMissing endDate: JsonField = JsonMissing.of(), + @JsonProperty("errorReasons") + @ExcludeMissing + errorReasons: JsonField> = JsonMissing.of(), + @JsonProperty("extensions") + @ExcludeMissing + extensions: JsonField> = JsonMissing.of(), + @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), + @JsonProperty("generatedAt") + @ExcludeMissing + generatedAt: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("startDate") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("statusCodes") + @ExcludeMissing + statusCodes: JsonField> = JsonMissing.of(), + @JsonProperty("top404Assets") + @ExcludeMissing + top404Assets: JsonField> = JsonMissing.of(), + @JsonProperty("topImages") + @ExcludeMissing + topImages: JsonField = JsonMissing.of(), + @JsonProperty("topImageTransforms") + @ExcludeMissing + topImageTransforms: JsonField = JsonMissing.of(), + @JsonProperty("topOtherAssets") + @ExcludeMissing + topOtherAssets: JsonField = JsonMissing.of(), + @JsonProperty("topReferrers") + @ExcludeMissing + topReferrers: JsonField = JsonMissing.of(), + @JsonProperty("topUserAgents") + @ExcludeMissing + topUserAgents: JsonField = JsonMissing.of(), + @JsonProperty("topVideos") + @ExcludeMissing + topVideos: JsonField = JsonMissing.of(), + @JsonProperty("topVideoTransforms") + @ExcludeMissing + topVideoTransforms: JsonField = JsonMissing.of(), + @JsonProperty("urlEndpoints") + @ExcludeMissing + urlEndpoints: JsonField = JsonMissing.of(), + @JsonProperty("videoProcessing") + @ExcludeMissing + videoProcessing: JsonField> = JsonMissing.of(), + ) : this( + bandwidthBytes, + browser, + cache, + country, + device, + endDate, + errorReasons, + extensions, + format, + generatedAt, + requestCount, + startDate, + statusCodes, + top404Assets, + topImages, + topImageTransforms, + topOtherAssets, + topReferrers, + topUserAgents, + topVideos, + topVideoTransforms, + urlEndpoints, + videoProcessing, + mutableMapOf(), + ) + + /** + * Total bandwidth, in bytes, utilized during the specified date range. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * CDN traffic grouped by browser. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun browser(): Browser = browser.getRequired("browser") + + /** + * CDN cache hit, miss and error counts for the date range. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cache(): Cache = cache.getRequired("cache") + + /** + * CDN traffic grouped by country. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun country(): Country = country.getRequired("country") + + /** + * CDN traffic grouped by device and operating system (e.g. `Desktop - Apple Mac`, `Smartphone - + * Apple iPhone`). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun device(): Device = device.getRequired("device") + + /** + * End date of the computed analytics data. + * + * @throws ImageKitInvalidDataException if 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("endDate") + + /** + * Request count grouped by origin error reason. This covers failed origin fetches, such as an + * asset not found at origin or an origin timeout. It is not the HTTP status code returned to + * the client, see `statusCodes` for that. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun errorReasons(): List = errorReasons.getRequired("errorReasons") + + /** + * Raw per-extension operation counts for the date range. These are raw operation counts, not + * billable extension units. For billable usage, use the `/v1/accounts/usage` endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun extensions(): List = extensions.getRequired("extensions") + + /** + * CDN traffic grouped by response `Content-Type`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun format(): Format = format.getRequired("format") + + /** + * Date and time when the analytics data was computed. Use this to gauge how fresh the returned + * data is. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun generatedAt(): OffsetDateTime = generatedAt.getRequired("generatedAt") + + /** + * Total number of requests made during the specified date range. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Start date of the computed analytics data. + * + * @throws ImageKitInvalidDataException if 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("startDate") + + /** + * Request count grouped by HTTP status code. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statusCodes(): List = statusCodes.getRequired("statusCodes") + + /** + * Top URLs that returned a 404 response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun top404Assets(): List = top404Assets.getRequired("top404Assets") + + /** + * Top image assets by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topImages(): TopImages = topImages.getRequired("topImages") + + /** + * Top image transformation strings by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topImageTransforms(): TopImageTransforms = + topImageTransforms.getRequired("topImageTransforms") + + /** + * Top non-image, non-video assets by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topOtherAssets(): TopOtherAssets = topOtherAssets.getRequired("topOtherAssets") + + /** + * Top HTTP referrers by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topReferrers(): TopReferrers = topReferrers.getRequired("topReferrers") + + /** + * Top user agents by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topUserAgents(): TopUserAgents = topUserAgents.getRequired("topUserAgents") + + /** + * Top video assets by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topVideos(): TopVideos = topVideos.getRequired("topVideos") + + /** + * Top video transformation strings by traffic. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topVideoTransforms(): TopVideoTransforms = + topVideoTransforms.getRequired("topVideoTransforms") + + /** + * CDN traffic grouped by configured URL endpoint. Traffic that does not match any named URL + * endpoint pattern is grouped under `Default`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun urlEndpoints(): UrlEndpoints = urlEndpoints.getRequired("urlEndpoints") + + /** + * Raw observed video transcode output duration, in seconds, grouped by resolution and codec. + * These are raw seconds, not billable Video Processing Units (VPU). For billable VPU totals, + * use the `/v1/accounts/usage` endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun videoProcessing(): List = videoProcessing.getRequired("videoProcessing") + + /** + * Returns the raw JSON value of [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [browser]. + * + * Unlike [browser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("browser") @ExcludeMissing fun _browser(): JsonField = browser + + /** + * Returns the raw JSON value of [cache]. + * + * Unlike [cache], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cache") @ExcludeMissing fun _cache(): JsonField = cache + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [device]. + * + * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("endDate") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [errorReasons]. + * + * Unlike [errorReasons], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("errorReasons") + @ExcludeMissing + fun _errorReasons(): JsonField> = errorReasons + + /** + * Returns the raw JSON value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): JsonField> = extensions + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [generatedAt]. + * + * Unlike [generatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("generatedAt") + @ExcludeMissing + fun _generatedAt(): JsonField = generatedAt + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("startDate") @ExcludeMissing fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [statusCodes]. + * + * Unlike [statusCodes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statusCodes") + @ExcludeMissing + fun _statusCodes(): JsonField> = statusCodes + + /** + * Returns the raw JSON value of [top404Assets]. + * + * Unlike [top404Assets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("top404Assets") + @ExcludeMissing + fun _top404Assets(): JsonField> = top404Assets + + /** + * Returns the raw JSON value of [topImages]. + * + * Unlike [topImages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topImages") @ExcludeMissing fun _topImages(): JsonField = topImages + + /** + * Returns the raw JSON value of [topImageTransforms]. + * + * Unlike [topImageTransforms], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("topImageTransforms") + @ExcludeMissing + fun _topImageTransforms(): JsonField = topImageTransforms + + /** + * Returns the raw JSON value of [topOtherAssets]. + * + * Unlike [topOtherAssets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topOtherAssets") + @ExcludeMissing + fun _topOtherAssets(): JsonField = topOtherAssets + + /** + * Returns the raw JSON value of [topReferrers]. + * + * Unlike [topReferrers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topReferrers") + @ExcludeMissing + fun _topReferrers(): JsonField = topReferrers + + /** + * Returns the raw JSON value of [topUserAgents]. + * + * Unlike [topUserAgents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topUserAgents") + @ExcludeMissing + fun _topUserAgents(): JsonField = topUserAgents + + /** + * Returns the raw JSON value of [topVideos]. + * + * Unlike [topVideos], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topVideos") @ExcludeMissing fun _topVideos(): JsonField = topVideos + + /** + * Returns the raw JSON value of [topVideoTransforms]. + * + * Unlike [topVideoTransforms], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("topVideoTransforms") + @ExcludeMissing + fun _topVideoTransforms(): JsonField = topVideoTransforms + + /** + * Returns the raw JSON value of [urlEndpoints]. + * + * Unlike [urlEndpoints], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlEndpoints") + @ExcludeMissing + fun _urlEndpoints(): JsonField = urlEndpoints + + /** + * Returns the raw JSON value of [videoProcessing]. + * + * Unlike [videoProcessing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoProcessing") + @ExcludeMissing + fun _videoProcessing(): JsonField> = videoProcessing + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageAnalyticsResponse]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .browser() + * .cache() + * .country() + * .device() + * .endDate() + * .errorReasons() + * .extensions() + * .format() + * .generatedAt() + * .requestCount() + * .startDate() + * .statusCodes() + * .top404Assets() + * .topImages() + * .topImageTransforms() + * .topOtherAssets() + * .topReferrers() + * .topUserAgents() + * .topVideos() + * .topVideoTransforms() + * .urlEndpoints() + * .videoProcessing() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageAnalyticsResponse]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var browser: JsonField? = null + private var cache: JsonField? = null + private var country: JsonField? = null + private var device: JsonField? = null + private var endDate: JsonField? = null + private var errorReasons: JsonField>? = null + private var extensions: JsonField>? = null + private var format: JsonField? = null + private var generatedAt: JsonField? = null + private var requestCount: JsonField? = null + private var startDate: JsonField? = null + private var statusCodes: JsonField>? = null + private var top404Assets: JsonField>? = null + private var topImages: JsonField? = null + private var topImageTransforms: JsonField? = null + private var topOtherAssets: JsonField? = null + private var topReferrers: JsonField? = null + private var topUserAgents: JsonField? = null + private var topVideos: JsonField? = null + private var topVideoTransforms: JsonField? = null + private var urlEndpoints: JsonField? = null + private var videoProcessing: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageAnalyticsResponse: UsageAnalyticsResponse) = apply { + bandwidthBytes = usageAnalyticsResponse.bandwidthBytes + browser = usageAnalyticsResponse.browser + cache = usageAnalyticsResponse.cache + country = usageAnalyticsResponse.country + device = usageAnalyticsResponse.device + endDate = usageAnalyticsResponse.endDate + errorReasons = usageAnalyticsResponse.errorReasons.map { it.toMutableList() } + extensions = usageAnalyticsResponse.extensions.map { it.toMutableList() } + format = usageAnalyticsResponse.format + generatedAt = usageAnalyticsResponse.generatedAt + requestCount = usageAnalyticsResponse.requestCount + startDate = usageAnalyticsResponse.startDate + statusCodes = usageAnalyticsResponse.statusCodes.map { it.toMutableList() } + top404Assets = usageAnalyticsResponse.top404Assets.map { it.toMutableList() } + topImages = usageAnalyticsResponse.topImages + topImageTransforms = usageAnalyticsResponse.topImageTransforms + topOtherAssets = usageAnalyticsResponse.topOtherAssets + topReferrers = usageAnalyticsResponse.topReferrers + topUserAgents = usageAnalyticsResponse.topUserAgents + topVideos = usageAnalyticsResponse.topVideos + topVideoTransforms = usageAnalyticsResponse.topVideoTransforms + urlEndpoints = usageAnalyticsResponse.urlEndpoints + videoProcessing = usageAnalyticsResponse.videoProcessing.map { it.toMutableList() } + additionalProperties = usageAnalyticsResponse.additionalProperties.toMutableMap() + } + + /** Total bandwidth, in bytes, utilized during the specified date range. */ + fun bandwidthBytes(bandwidthBytes: Double) = bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** CDN traffic grouped by browser. */ + fun browser(browser: Browser) = browser(JsonField.of(browser)) + + /** + * Sets [Builder.browser] to an arbitrary JSON value. + * + * You should usually call [Builder.browser] with a well-typed [Browser] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun browser(browser: JsonField) = apply { this.browser = browser } + + /** CDN cache hit, miss and error counts for the date range. */ + fun cache(cache: Cache) = cache(JsonField.of(cache)) + + /** + * Sets [Builder.cache] to an arbitrary JSON value. + * + * You should usually call [Builder.cache] with a well-typed [Cache] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cache(cache: JsonField) = apply { this.cache = cache } + + /** CDN traffic grouped by country. */ + fun country(country: Country) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [Country] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** + * CDN traffic grouped by device and operating system (e.g. `Desktop - Apple Mac`, + * `Smartphone - Apple iPhone`). + */ + fun device(device: Device) = device(JsonField.of(device)) + + /** + * Sets [Builder.device] to an arbitrary JSON value. + * + * You should usually call [Builder.device] with a well-typed [Device] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun device(device: JsonField) = apply { this.device = device } + + /** End date of the computed analytics data. */ + 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 } + + /** + * Request count grouped by origin error reason. This covers failed origin fetches, such as + * an asset not found at origin or an origin timeout. It is not the HTTP status code + * returned to the client, see `statusCodes` for that. + */ + fun errorReasons(errorReasons: List) = errorReasons(JsonField.of(errorReasons)) + + /** + * Sets [Builder.errorReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.errorReasons] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun errorReasons(errorReasons: JsonField>) = apply { + this.errorReasons = errorReasons.map { it.toMutableList() } + } + + /** + * Adds a single [ErrorReason] to [errorReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addErrorReason(errorReason: ErrorReason) = apply { + errorReasons = + (errorReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("errorReasons", it).add(errorReason) + } + } + + /** + * Raw per-extension operation counts for the date range. These are raw operation counts, + * not billable extension units. For billable usage, use the `/v1/accounts/usage` endpoint. + */ + fun extensions(extensions: List) = extensions(JsonField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary JSON value. + * + * You should usually call [Builder.extensions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extensions(extensions: JsonField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: JsonField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** CDN traffic grouped by response `Content-Type`. */ + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** + * Date and time when the analytics data was computed. Use this to gauge how fresh the + * returned data is. The date and time is in ISO8601 format. + */ + fun generatedAt(generatedAt: OffsetDateTime) = generatedAt(JsonField.of(generatedAt)) + + /** + * Sets [Builder.generatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.generatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun generatedAt(generatedAt: JsonField) = apply { + this.generatedAt = generatedAt + } + + /** Total number of requests made during the specified date range. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Start date of the computed analytics data. */ + 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 } + + /** Request count grouped by HTTP status code. */ + fun statusCodes(statusCodes: List) = statusCodes(JsonField.of(statusCodes)) + + /** + * Sets [Builder.statusCodes] to an arbitrary JSON value. + * + * You should usually call [Builder.statusCodes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusCodes(statusCodes: JsonField>) = apply { + this.statusCodes = statusCodes.map { it.toMutableList() } + } + + /** + * Adds a single [StatusCode] to [statusCodes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStatusCode(statusCode: StatusCode) = apply { + statusCodes = + (statusCodes ?: JsonField.of(mutableListOf())).also { + checkKnown("statusCodes", it).add(statusCode) + } + } + + /** Top URLs that returned a 404 response. */ + fun top404Assets(top404Assets: List) = top404Assets(JsonField.of(top404Assets)) + + /** + * Sets [Builder.top404Assets] to an arbitrary JSON value. + * + * You should usually call [Builder.top404Assets] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun top404Assets(top404Assets: JsonField>) = apply { + this.top404Assets = top404Assets.map { it.toMutableList() } + } + + /** + * Adds a single [Top404Asset] to [top404Assets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTop404Asset(top404Asset: Top404Asset) = apply { + top404Assets = + (top404Assets ?: JsonField.of(mutableListOf())).also { + checkKnown("top404Assets", it).add(top404Asset) + } + } + + /** Top image assets by traffic. */ + fun topImages(topImages: TopImages) = topImages(JsonField.of(topImages)) + + /** + * Sets [Builder.topImages] to an arbitrary JSON value. + * + * You should usually call [Builder.topImages] with a well-typed [TopImages] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topImages(topImages: JsonField) = apply { this.topImages = topImages } + + /** Top image transformation strings by traffic. */ + fun topImageTransforms(topImageTransforms: TopImageTransforms) = + topImageTransforms(JsonField.of(topImageTransforms)) + + /** + * Sets [Builder.topImageTransforms] to an arbitrary JSON value. + * + * You should usually call [Builder.topImageTransforms] with a well-typed + * [TopImageTransforms] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun topImageTransforms(topImageTransforms: JsonField) = apply { + this.topImageTransforms = topImageTransforms + } + + /** Top non-image, non-video assets by traffic. */ + fun topOtherAssets(topOtherAssets: TopOtherAssets) = + topOtherAssets(JsonField.of(topOtherAssets)) + + /** + * Sets [Builder.topOtherAssets] to an arbitrary JSON value. + * + * You should usually call [Builder.topOtherAssets] with a well-typed [TopOtherAssets] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topOtherAssets(topOtherAssets: JsonField) = apply { + this.topOtherAssets = topOtherAssets + } + + /** Top HTTP referrers by traffic. */ + fun topReferrers(topReferrers: TopReferrers) = topReferrers(JsonField.of(topReferrers)) + + /** + * Sets [Builder.topReferrers] to an arbitrary JSON value. + * + * You should usually call [Builder.topReferrers] with a well-typed [TopReferrers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topReferrers(topReferrers: JsonField) = apply { + this.topReferrers = topReferrers + } + + /** Top user agents by traffic. */ + fun topUserAgents(topUserAgents: TopUserAgents) = topUserAgents(JsonField.of(topUserAgents)) + + /** + * Sets [Builder.topUserAgents] to an arbitrary JSON value. + * + * You should usually call [Builder.topUserAgents] with a well-typed [TopUserAgents] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topUserAgents(topUserAgents: JsonField) = apply { + this.topUserAgents = topUserAgents + } + + /** Top video assets by traffic. */ + fun topVideos(topVideos: TopVideos) = topVideos(JsonField.of(topVideos)) + + /** + * Sets [Builder.topVideos] to an arbitrary JSON value. + * + * You should usually call [Builder.topVideos] with a well-typed [TopVideos] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topVideos(topVideos: JsonField) = apply { this.topVideos = topVideos } + + /** Top video transformation strings by traffic. */ + fun topVideoTransforms(topVideoTransforms: TopVideoTransforms) = + topVideoTransforms(JsonField.of(topVideoTransforms)) + + /** + * Sets [Builder.topVideoTransforms] to an arbitrary JSON value. + * + * You should usually call [Builder.topVideoTransforms] with a well-typed + * [TopVideoTransforms] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun topVideoTransforms(topVideoTransforms: JsonField) = apply { + this.topVideoTransforms = topVideoTransforms + } + + /** + * CDN traffic grouped by configured URL endpoint. Traffic that does not match any named URL + * endpoint pattern is grouped under `Default`. + */ + fun urlEndpoints(urlEndpoints: UrlEndpoints) = urlEndpoints(JsonField.of(urlEndpoints)) + + /** + * Sets [Builder.urlEndpoints] to an arbitrary JSON value. + * + * You should usually call [Builder.urlEndpoints] with a well-typed [UrlEndpoints] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun urlEndpoints(urlEndpoints: JsonField) = apply { + this.urlEndpoints = urlEndpoints + } + + /** + * Raw observed video transcode output duration, in seconds, grouped by resolution and + * codec. These are raw seconds, not billable Video Processing Units (VPU). For billable VPU + * totals, use the `/v1/accounts/usage` endpoint. + */ + fun videoProcessing(videoProcessing: List) = + videoProcessing(JsonField.of(videoProcessing)) + + /** + * Sets [Builder.videoProcessing] to an arbitrary JSON value. + * + * You should usually call [Builder.videoProcessing] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun videoProcessing(videoProcessing: JsonField>) = apply { + this.videoProcessing = videoProcessing.map { it.toMutableList() } + } + + /** + * Adds a single [VideoProcessing] to [Builder.videoProcessing]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVideoProcessing(videoProcessing: VideoProcessing) = apply { + this.videoProcessing = + (this.videoProcessing ?: JsonField.of(mutableListOf())).also { + checkKnown("videoProcessing", it).add(videoProcessing) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageAnalyticsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .browser() + * .cache() + * .country() + * .device() + * .endDate() + * .errorReasons() + * .extensions() + * .format() + * .generatedAt() + * .requestCount() + * .startDate() + * .statusCodes() + * .top404Assets() + * .topImages() + * .topImageTransforms() + * .topOtherAssets() + * .topReferrers() + * .topUserAgents() + * .topVideos() + * .topVideoTransforms() + * .urlEndpoints() + * .videoProcessing() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageAnalyticsResponse = + UsageAnalyticsResponse( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("browser", browser), + checkRequired("cache", cache), + checkRequired("country", country), + checkRequired("device", device), + checkRequired("endDate", endDate), + checkRequired("errorReasons", errorReasons).map { it.toImmutable() }, + checkRequired("extensions", extensions).map { it.toImmutable() }, + checkRequired("format", format), + checkRequired("generatedAt", generatedAt), + checkRequired("requestCount", requestCount), + checkRequired("startDate", startDate), + checkRequired("statusCodes", statusCodes).map { it.toImmutable() }, + checkRequired("top404Assets", top404Assets).map { it.toImmutable() }, + checkRequired("topImages", topImages), + checkRequired("topImageTransforms", topImageTransforms), + checkRequired("topOtherAssets", topOtherAssets), + checkRequired("topReferrers", topReferrers), + checkRequired("topUserAgents", topUserAgents), + checkRequired("topVideos", topVideos), + checkRequired("topVideoTransforms", topVideoTransforms), + checkRequired("urlEndpoints", urlEndpoints), + checkRequired("videoProcessing", videoProcessing).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UsageAnalyticsResponse = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + browser().validate() + cache().validate() + country().validate() + device().validate() + endDate() + errorReasons().forEach { it.validate() } + extensions().forEach { it.validate() } + format().validate() + generatedAt() + requestCount() + startDate() + statusCodes().forEach { it.validate() } + top404Assets().forEach { it.validate() } + topImages().validate() + topImageTransforms().validate() + topOtherAssets().validate() + topReferrers().validate() + topUserAgents().validate() + topVideos().validate() + topVideoTransforms().validate() + urlEndpoints().validate() + videoProcessing().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (browser.asKnown().getOrNull()?.validity() ?: 0) + + (cache.asKnown().getOrNull()?.validity() ?: 0) + + (country.asKnown().getOrNull()?.validity() ?: 0) + + (device.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (errorReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (extensions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (generatedAt.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (statusCodes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (top404Assets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (topImages.asKnown().getOrNull()?.validity() ?: 0) + + (topImageTransforms.asKnown().getOrNull()?.validity() ?: 0) + + (topOtherAssets.asKnown().getOrNull()?.validity() ?: 0) + + (topReferrers.asKnown().getOrNull()?.validity() ?: 0) + + (topUserAgents.asKnown().getOrNull()?.validity() ?: 0) + + (topVideos.asKnown().getOrNull()?.validity() ?: 0) + + (topVideoTransforms.asKnown().getOrNull()?.validity() ?: 0) + + (urlEndpoints.asKnown().getOrNull()?.validity() ?: 0) + + (videoProcessing.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** CDN traffic grouped by browser. */ + class Browser + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top browsers sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top browsers sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Browser]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Browser]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browser: Browser) = apply { + byBandwidth = browser.byBandwidth.map { it.toMutableList() } + byRequests = browser.byRequests.map { it.toMutableList() } + additionalProperties = browser.additionalProperties.toMutableMap() + } + + /** Top browsers sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top browsers sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Browser]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Browser = + Browser( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Browser = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Browser name (e.g. `Chrome`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Browser name (e.g. `Chrome`). */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Browser name (e.g. `Chrome`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Browser name (e.g. `Chrome`). */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Browser && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Browser{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** CDN cache hit, miss and error counts for the date range. */ + class Cache + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val errorCount: JsonField, + private val hitCount: JsonField, + private val missCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("errorCount") + @ExcludeMissing + errorCount: JsonField = JsonMissing.of(), + @JsonProperty("hitCount") + @ExcludeMissing + hitCount: JsonField = JsonMissing.of(), + @JsonProperty("missCount") + @ExcludeMissing + missCount: JsonField = JsonMissing.of(), + ) : this(errorCount, hitCount, missCount, mutableMapOf()) + + /** + * Number of requests where the CDN encountered a cache error or exceeded capacity while + * serving the response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun errorCount(): Double = errorCount.getRequired("errorCount") + + /** + * Number of requests served from cache, including full hits and revalidated hits. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hitCount(): Double = hitCount.getRequired("hitCount") + + /** + * Number of requests that were not found in cache and had to be fetched from origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun missCount(): Double = missCount.getRequired("missCount") + + /** + * Returns the raw JSON value of [errorCount]. + * + * Unlike [errorCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("errorCount") + @ExcludeMissing + fun _errorCount(): JsonField = errorCount + + /** + * Returns the raw JSON value of [hitCount]. + * + * Unlike [hitCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hitCount") @ExcludeMissing fun _hitCount(): JsonField = hitCount + + /** + * Returns the raw JSON value of [missCount]. + * + * Unlike [missCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("missCount") @ExcludeMissing fun _missCount(): JsonField = missCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Cache]. + * + * The following fields are required: + * ```java + * .errorCount() + * .hitCount() + * .missCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cache]. */ + class Builder internal constructor() { + + private var errorCount: JsonField? = null + private var hitCount: JsonField? = null + private var missCount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cache: Cache) = apply { + errorCount = cache.errorCount + hitCount = cache.hitCount + missCount = cache.missCount + additionalProperties = cache.additionalProperties.toMutableMap() + } + + /** + * Number of requests where the CDN encountered a cache error or exceeded capacity while + * serving the response. + */ + fun errorCount(errorCount: Double) = errorCount(JsonField.of(errorCount)) + + /** + * Sets [Builder.errorCount] to an arbitrary JSON value. + * + * You should usually call [Builder.errorCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun errorCount(errorCount: JsonField) = apply { this.errorCount = errorCount } + + /** Number of requests served from cache, including full hits and revalidated hits. */ + fun hitCount(hitCount: Double) = hitCount(JsonField.of(hitCount)) + + /** + * Sets [Builder.hitCount] to an arbitrary JSON value. + * + * You should usually call [Builder.hitCount] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hitCount(hitCount: JsonField) = apply { this.hitCount = hitCount } + + /** + * Number of requests that were not found in cache and had to be fetched from origin. + */ + fun missCount(missCount: Double) = missCount(JsonField.of(missCount)) + + /** + * Sets [Builder.missCount] to an arbitrary JSON value. + * + * You should usually call [Builder.missCount] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun missCount(missCount: JsonField) = apply { this.missCount = missCount } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Cache]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .errorCount() + * .hitCount() + * .missCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Cache = + Cache( + checkRequired("errorCount", errorCount), + checkRequired("hitCount", hitCount), + checkRequired("missCount", missCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Cache = apply { + if (validated) { + return@apply + } + + errorCount() + hitCount() + missCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (errorCount.asKnown().isPresent) 1 else 0) + + (if (hitCount.asKnown().isPresent) 1 else 0) + + (if (missCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cache && + errorCount == other.errorCount && + hitCount == other.hitCount && + missCount == other.missCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(errorCount, hitCount, missCount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cache{errorCount=$errorCount, hitCount=$hitCount, missCount=$missCount, additionalProperties=$additionalProperties}" + } + + /** CDN traffic grouped by country. */ + class Country + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top requesting countries sorted by total bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top requesting countries sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Country]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Country]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(country: Country) = apply { + byBandwidth = country.byBandwidth.map { it.toMutableList() } + byRequests = country.byRequests.map { it.toMutableList() } + additionalProperties = country.additionalProperties.toMutableMap() + } + + /** Top requesting countries sorted by total bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top requesting countries sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Country]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Country = + Country( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Country = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val code: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, code, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * ISO country code. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun code(): String = code.getRequired("code") + + /** + * Country name. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .code() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var code: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + code = byBandwidth.code + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** ISO country code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + /** Country name. */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .code() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("code", code), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + code() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + (if (code.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + code == other.code && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, code, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, code=$code, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val code: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, code, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * ISO country code. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun code(): String = code.getRequired("code") + + /** + * Country name. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .code() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var code: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + code = byRequest.code + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** ISO country code. */ + fun code(code: String) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + /** Country name. */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .code() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("code", code), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + code() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + (if (code.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + code == other.code && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, code, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, code=$code, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Country && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Country{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** + * CDN traffic grouped by device and operating system (e.g. `Desktop - Apple Mac`, `Smartphone - + * Apple iPhone`). + */ + class Device + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top device/OS combinations sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top device/OS combinations sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Device]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Device]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(device: Device) = apply { + byBandwidth = device.byBandwidth.map { it.toMutableList() } + byRequests = device.byRequests.map { it.toMutableList() } + additionalProperties = device.additionalProperties.toMutableMap() + } + + /** Top device/OS combinations sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top device/OS combinations sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Device]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Device = + Device( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Device = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Device category combined with operating system or vendor (e.g. `Desktop - Windows + * PC`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** + * Device category combined with operating system or vendor (e.g. `Desktop - Windows + * PC`). + */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Device category combined with operating system or vendor (e.g. `Desktop - Windows + * PC`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** + * Device category combined with operating system or vendor (e.g. `Desktop - Windows + * PC`). + */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Device && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Device{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + class ErrorReason + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val requestCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + ) : this(name, requestCount, mutableMapOf()) + + /** + * Description of the error reason. + * + * @throws ImageKitInvalidDataException if 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") + + /** + * Number of requests that failed with this error reason. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * 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 [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ErrorReason]. + * + * The following fields are required: + * ```java + * .name() + * .requestCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ErrorReason]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var requestCount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(errorReason: ErrorReason) = apply { + name = errorReason.name + requestCount = errorReason.requestCount + additionalProperties = errorReason.additionalProperties.toMutableMap() + } + + /** Description of the error reason. */ + 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 } + + /** Number of requests that failed with this error reason. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ErrorReason]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .requestCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ErrorReason = + ErrorReason( + checkRequired("name", name), + checkRequired("requestCount", requestCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ErrorReason = apply { + if (validated) { + return@apply + } + + name() + requestCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ErrorReason && + name == other.name && + requestCount == other.requestCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, requestCount, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ErrorReason{name=$name, requestCount=$requestCount, additionalProperties=$additionalProperties}" + } + + class Extension + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val operationCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("operationCount") + @ExcludeMissing + operationCount: JsonField = JsonMissing.of(), + ) : this(name, operationCount, mutableMapOf()) + + /** + * Extension identifier. + * + * @throws ImageKitInvalidDataException if 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") + + /** + * Number of times this extension ran during the date range. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operationCount(): Double = operationCount.getRequired("operationCount") + + /** + * 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 [operationCount]. + * + * Unlike [operationCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operationCount") + @ExcludeMissing + fun _operationCount(): JsonField = operationCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Extension]. + * + * The following fields are required: + * ```java + * .name() + * .operationCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Extension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var operationCount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extension: Extension) = apply { + name = extension.name + operationCount = extension.operationCount + additionalProperties = extension.additionalProperties.toMutableMap() + } + + /** Extension identifier. */ + 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 } + + /** Number of times this extension ran during the date range. */ + fun operationCount(operationCount: Double) = + operationCount(JsonField.of(operationCount)) + + /** + * Sets [Builder.operationCount] to an arbitrary JSON value. + * + * You should usually call [Builder.operationCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operationCount(operationCount: JsonField) = apply { + this.operationCount = operationCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Extension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .operationCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Extension = + Extension( + checkRequired("name", name), + checkRequired("operationCount", operationCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + name() + operationCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (operationCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + name == other.name && + operationCount == other.operationCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, operationCount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Extension{name=$name, operationCount=$operationCount, additionalProperties=$additionalProperties}" + } + + /** CDN traffic grouped by response `Content-Type`. */ + class Format + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top content types sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top content types sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Format]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Format]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(format: Format) = apply { + byBandwidth = format.byBandwidth.map { it.toMutableList() } + byRequests = format.byRequests.map { it.toMutableList() } + additionalProperties = format.additionalProperties.toMutableMap() + } + + /** Top content types sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top content types sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Format]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Format = + Format( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Format = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * MIME type (e.g. `image/webp`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** MIME type (e.g. `image/webp`). */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * MIME type (e.g. `image/webp`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** MIME type (e.g. `image/webp`). */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Format{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + class StatusCode + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val requestCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + ) : this(name, requestCount, mutableMapOf()) + + /** + * HTTP status code. + * + * @throws ImageKitInvalidDataException if 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") + + /** + * Number of requests that received this status code. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * 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 [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StatusCode]. + * + * The following fields are required: + * ```java + * .name() + * .requestCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StatusCode]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var requestCount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(statusCode: StatusCode) = apply { + name = statusCode.name + requestCount = statusCode.requestCount + additionalProperties = statusCode.additionalProperties.toMutableMap() + } + + /** HTTP status code. */ + 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 } + + /** Number of requests that received this status code. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StatusCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .requestCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StatusCode = + StatusCode( + checkRequired("name", name), + checkRequired("requestCount", requestCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): StatusCode = apply { + if (validated) { + return@apply + } + + name() + requestCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StatusCode && + name == other.name && + requestCount == other.requestCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, requestCount, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StatusCode{name=$name, requestCount=$requestCount, additionalProperties=$additionalProperties}" + } + + class Top404Asset + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val requestCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + ) : this(name, requestCount, mutableMapOf()) + + /** + * URL that returned a 404 response. + * + * @throws ImageKitInvalidDataException if 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") + + /** + * Number of requests to this URL that returned a 404 response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * 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 [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Top404Asset]. + * + * The following fields are required: + * ```java + * .name() + * .requestCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Top404Asset]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var requestCount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(top404Asset: Top404Asset) = apply { + name = top404Asset.name + requestCount = top404Asset.requestCount + additionalProperties = top404Asset.additionalProperties.toMutableMap() + } + + /** URL that returned a 404 response. */ + 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 } + + /** Number of requests to this URL that returned a 404 response. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Top404Asset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .requestCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Top404Asset = + Top404Asset( + checkRequired("name", name), + checkRequired("requestCount", requestCount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Top404Asset = apply { + if (validated) { + return@apply + } + + name() + requestCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (requestCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Top404Asset && + name == other.name && + requestCount == other.requestCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, requestCount, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Top404Asset{name=$name, requestCount=$requestCount, additionalProperties=$additionalProperties}" + } + + /** Top image assets by traffic. */ + class TopImages + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top image assets sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top image assets sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopImages]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopImages]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topImages: TopImages) = apply { + byBandwidth = topImages.byBandwidth.map { it.toMutableList() } + byRequests = topImages.byRequests.map { it.toMutableList() } + additionalProperties = topImages.additionalProperties.toMutableMap() + } + + /** Top image assets sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top image assets sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopImages]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopImages = + TopImages( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopImages = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL of the image asset. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** URL of the image asset. */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL of the image asset. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** URL of the image asset. */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopImages && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopImages{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** Top image transformation strings by traffic. */ + class TopImageTransforms + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top image transformation strings sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top image transformation strings sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopImageTransforms]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopImageTransforms]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topImageTransforms: TopImageTransforms) = apply { + byBandwidth = topImageTransforms.byBandwidth.map { it.toMutableList() } + byRequests = topImageTransforms.byRequests.map { it.toMutableList() } + additionalProperties = topImageTransforms.additionalProperties.toMutableMap() + } + + /** Top image transformation strings sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top image transformation strings sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopImageTransforms]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopImageTransforms = + TopImageTransforms( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopImageTransforms = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Image transformation string (e.g. `tr:w-400,h-400`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Image transformation string (e.g. `tr:w-400,h-400`). */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Image transformation string (e.g. `tr:w-400,h-400`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Image transformation string (e.g. `tr:w-400,h-400`). */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopImageTransforms && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopImageTransforms{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** Top non-image, non-video assets by traffic. */ + class TopOtherAssets + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top non-image, non-video assets sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top non-image, non-video assets sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopOtherAssets]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopOtherAssets]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topOtherAssets: TopOtherAssets) = apply { + byBandwidth = topOtherAssets.byBandwidth.map { it.toMutableList() } + byRequests = topOtherAssets.byRequests.map { it.toMutableList() } + additionalProperties = topOtherAssets.additionalProperties.toMutableMap() + } + + /** Top non-image, non-video assets sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top non-image, non-video assets sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopOtherAssets]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopOtherAssets = + TopOtherAssets( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopOtherAssets = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL of the non-image, non-video asset. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** URL of the non-image, non-video asset. */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL of the non-image, non-video asset. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** URL of the non-image, non-video asset. */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopOtherAssets && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopOtherAssets{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** Top HTTP referrers by traffic. */ + class TopReferrers + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top HTTP referrers sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top HTTP referrers sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopReferrers]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopReferrers]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topReferrers: TopReferrers) = apply { + byBandwidth = topReferrers.byBandwidth.map { it.toMutableList() } + byRequests = topReferrers.byRequests.map { it.toMutableList() } + additionalProperties = topReferrers.additionalProperties.toMutableMap() + } + + /** Top HTTP referrers sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top HTTP referrers sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopReferrers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopReferrers = + TopReferrers( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopReferrers = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Referrer URL. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Referrer URL. */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Referrer URL. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Referrer URL. */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopReferrers && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopReferrers{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** Top user agents by traffic. */ + class TopUserAgents + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top user agents sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top user agents sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopUserAgents]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopUserAgents]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topUserAgents: TopUserAgents) = apply { + byBandwidth = topUserAgents.byBandwidth.map { it.toMutableList() } + byRequests = topUserAgents.byRequests.map { it.toMutableList() } + additionalProperties = topUserAgents.additionalProperties.toMutableMap() + } + + /** Top user agents sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top user agents sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopUserAgents]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopUserAgents = + TopUserAgents( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopUserAgents = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * User agent string. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** User agent string. */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * User agent string. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** User agent string. */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopUserAgents && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopUserAgents{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** Top video assets by traffic. */ + class TopVideos + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top video assets sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top video assets sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopVideos]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopVideos]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topVideos: TopVideos) = apply { + byBandwidth = topVideos.byBandwidth.map { it.toMutableList() } + byRequests = topVideos.byRequests.map { it.toMutableList() } + additionalProperties = topVideos.additionalProperties.toMutableMap() + } + + /** Top video assets sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top video assets sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopVideos]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopVideos = + TopVideos( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopVideos = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL of the video asset. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** URL of the video asset. */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Full URL of the video asset (e.g. `https://ik.imagekit.io/demo/clip.mp4`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Full URL of the video asset (e.g. `https://ik.imagekit.io/demo/clip.mp4`). */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopVideos && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopVideos{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** Top video transformation strings by traffic. */ + class TopVideoTransforms + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top video transformation strings sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top video transformation strings sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopVideoTransforms]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopVideoTransforms]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topVideoTransforms: TopVideoTransforms) = apply { + byBandwidth = topVideoTransforms.byBandwidth.map { it.toMutableList() } + byRequests = topVideoTransforms.byRequests.map { it.toMutableList() } + additionalProperties = topVideoTransforms.additionalProperties.toMutableMap() + } + + /** Top video transformation strings sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top video transformation strings sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopVideoTransforms]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopVideoTransforms = + TopVideoTransforms( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TopVideoTransforms = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Video transformation string (e.g. `tr:h-720,f-mp4`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Video transformation string (e.g. `tr:h-720,f-mp4`). */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * Video transformation string (e.g. `tr:h-720,f-mp4`). + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** Video transformation string (e.g. `tr:h-720,f-mp4`). */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopVideoTransforms && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopVideoTransforms{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + /** + * CDN traffic grouped by configured URL endpoint. Traffic that does not match any named URL + * endpoint pattern is grouped under `Default`. + */ + class UrlEndpoints + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byBandwidth: JsonField>, + private val byRequests: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("byBandwidth") + @ExcludeMissing + byBandwidth: JsonField> = JsonMissing.of(), + @JsonProperty("byRequests") + @ExcludeMissing + byRequests: JsonField> = JsonMissing.of(), + ) : this(byBandwidth, byRequests, mutableMapOf()) + + /** + * Top URL endpoints sorted by bandwidth utilized. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byBandwidth(): List = byBandwidth.getRequired("byBandwidth") + + /** + * Top URL endpoints sorted by request count. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun byRequests(): List = byRequests.getRequired("byRequests") + + /** + * Returns the raw JSON value of [byBandwidth]. + * + * Unlike [byBandwidth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byBandwidth") + @ExcludeMissing + fun _byBandwidth(): JsonField> = byBandwidth + + /** + * Returns the raw JSON value of [byRequests]. + * + * Unlike [byRequests], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("byRequests") + @ExcludeMissing + fun _byRequests(): JsonField> = byRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UrlEndpoints]. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpoints]. */ + class Builder internal constructor() { + + private var byBandwidth: JsonField>? = null + private var byRequests: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(urlEndpoints: UrlEndpoints) = apply { + byBandwidth = urlEndpoints.byBandwidth.map { it.toMutableList() } + byRequests = urlEndpoints.byRequests.map { it.toMutableList() } + additionalProperties = urlEndpoints.additionalProperties.toMutableMap() + } + + /** Top URL endpoints sorted by bandwidth utilized. */ + fun byBandwidth(byBandwidth: List) = byBandwidth(JsonField.of(byBandwidth)) + + /** + * Sets [Builder.byBandwidth] to an arbitrary JSON value. + * + * You should usually call [Builder.byBandwidth] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byBandwidth(byBandwidth: JsonField>) = apply { + this.byBandwidth = byBandwidth.map { it.toMutableList() } + } + + /** + * Adds a single [ByBandwidth] to [Builder.byBandwidth]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByBandwidth(byBandwidth: ByBandwidth) = apply { + this.byBandwidth = + (this.byBandwidth ?: JsonField.of(mutableListOf())).also { + checkKnown("byBandwidth", it).add(byBandwidth) + } + } + + /** Top URL endpoints sorted by request count. */ + fun byRequests(byRequests: List) = byRequests(JsonField.of(byRequests)) + + /** + * Sets [Builder.byRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.byRequests] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun byRequests(byRequests: JsonField>) = apply { + this.byRequests = byRequests.map { it.toMutableList() } + } + + /** + * Adds a single [ByRequest] to [byRequests]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByRequest(byRequest: ByRequest) = apply { + byRequests = + (byRequests ?: JsonField.of(mutableListOf())).also { + checkKnown("byRequests", it).add(byRequest) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpoints]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .byBandwidth() + * .byRequests() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlEndpoints = + UrlEndpoints( + checkRequired("byBandwidth", byBandwidth).map { it.toImmutable() }, + checkRequired("byRequests", byRequests).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UrlEndpoints = apply { + if (validated) { + return@apply + } + + byBandwidth().forEach { it.validate() } + byRequests().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byBandwidth.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (byRequests.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class ByBandwidth + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL endpoint name, or `Default` for traffic that does not match a named endpoint. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByBandwidth]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByBandwidth]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byBandwidth: ByBandwidth) = apply { + bandwidthBytes = byBandwidth.bandwidthBytes + requestCount = byBandwidth.requestCount + name = byBandwidth.name + additionalProperties = byBandwidth.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** + * URL endpoint name, or `Default` for traffic that does not match a named endpoint. + */ + 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 [ByBandwidth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByBandwidth = + ByBandwidth( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByBandwidth = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByBandwidth && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByBandwidth{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + class ByRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bandwidthBytes: JsonField, + private val requestCount: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("requestCount") + @ExcludeMissing + requestCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(bandwidthBytes, requestCount, name, mutableMapOf()) + + fun toRequestBandwidthEntry(): RequestBandwidthEntry = + RequestBandwidthEntry.builder() + .bandwidthBytes(bandwidthBytes) + .requestCount(requestCount) + .build() + + /** + * Total bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bandwidthBytes(): Double = bandwidthBytes.getRequired("bandwidthBytes") + + /** + * Number of requests. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun requestCount(): Double = requestCount.getRequired("requestCount") + + /** + * URL endpoint name, or `Default` for traffic that does not match a named endpoint. + * + * @throws ImageKitInvalidDataException if 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 [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [requestCount]. + * + * Unlike [requestCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requestCount") + @ExcludeMissing + fun _requestCount(): JsonField = requestCount + + /** + * 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 [ByRequest]. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByRequest]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField? = null + private var requestCount: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byRequest: ByRequest) = apply { + bandwidthBytes = byRequest.bandwidthBytes + requestCount = byRequest.requestCount + name = byRequest.name + additionalProperties = byRequest.additionalProperties.toMutableMap() + } + + /** Total bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Double) = + bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of requests. */ + fun requestCount(requestCount: Double) = requestCount(JsonField.of(requestCount)) + + /** + * Sets [Builder.requestCount] to an arbitrary JSON value. + * + * You should usually call [Builder.requestCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requestCount(requestCount: JsonField) = apply { + this.requestCount = requestCount + } + + /** + * URL endpoint name, or `Default` for traffic that does not match a named endpoint. + */ + 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 [ByRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bandwidthBytes() + * .requestCount() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ByRequest = + ByRequest( + checkRequired("bandwidthBytes", bandwidthBytes), + checkRequired("requestCount", requestCount), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ByRequest = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + requestCount() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (requestCount.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 ByRequest && + bandwidthBytes == other.bandwidthBytes && + requestCount == other.requestCount && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bandwidthBytes, requestCount, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByRequest{bandwidthBytes=$bandwidthBytes, requestCount=$requestCount, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpoints && + byBandwidth == other.byBandwidth && + byRequests == other.byRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byBandwidth, byRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UrlEndpoints{byBandwidth=$byBandwidth, byRequests=$byRequests, additionalProperties=$additionalProperties}" + } + + class VideoProcessing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val codec: JsonField, + private val durationSeconds: JsonField, + private val resolution: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("codec") @ExcludeMissing codec: JsonField = JsonMissing.of(), + @JsonProperty("durationSeconds") + @ExcludeMissing + durationSeconds: JsonField = JsonMissing.of(), + @JsonProperty("resolution") + @ExcludeMissing + resolution: JsonField = JsonMissing.of(), + ) : this(codec, durationSeconds, resolution, mutableMapOf()) + + /** + * Video codec used for the output (e.g. `h264`, `av1`). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun codec(): String = codec.getRequired("codec") + + /** + * Total output duration, in seconds, for this resolution and codec combination. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun durationSeconds(): Double = durationSeconds.getRequired("durationSeconds") + + /** + * Output resolution tier (e.g. `SD`, `HD`, `4K`). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun resolution(): String = resolution.getRequired("resolution") + + /** + * Returns the raw JSON value of [codec]. + * + * Unlike [codec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("codec") @ExcludeMissing fun _codec(): JsonField = codec + + /** + * Returns the raw JSON value of [durationSeconds]. + * + * Unlike [durationSeconds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("durationSeconds") + @ExcludeMissing + fun _durationSeconds(): JsonField = durationSeconds + + /** + * Returns the raw JSON value of [resolution]. + * + * Unlike [resolution], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resolution") + @ExcludeMissing + fun _resolution(): JsonField = resolution + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VideoProcessing]. + * + * The following fields are required: + * ```java + * .codec() + * .durationSeconds() + * .resolution() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoProcessing]. */ + class Builder internal constructor() { + + private var codec: JsonField? = null + private var durationSeconds: JsonField? = null + private var resolution: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(videoProcessing: VideoProcessing) = apply { + codec = videoProcessing.codec + durationSeconds = videoProcessing.durationSeconds + resolution = videoProcessing.resolution + additionalProperties = videoProcessing.additionalProperties.toMutableMap() + } + + /** Video codec used for the output (e.g. `h264`, `av1`). */ + fun codec(codec: String) = codec(JsonField.of(codec)) + + /** + * Sets [Builder.codec] to an arbitrary JSON value. + * + * You should usually call [Builder.codec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun codec(codec: JsonField) = apply { this.codec = codec } + + /** Total output duration, in seconds, for this resolution and codec combination. */ + fun durationSeconds(durationSeconds: Double) = + durationSeconds(JsonField.of(durationSeconds)) + + /** + * Sets [Builder.durationSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.durationSeconds] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun durationSeconds(durationSeconds: JsonField) = apply { + this.durationSeconds = durationSeconds + } + + /** Output resolution tier (e.g. `SD`, `HD`, `4K`). */ + fun resolution(resolution: String) = resolution(JsonField.of(resolution)) + + /** + * Sets [Builder.resolution] to an arbitrary JSON value. + * + * You should usually call [Builder.resolution] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resolution(resolution: JsonField) = apply { this.resolution = resolution } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VideoProcessing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .codec() + * .durationSeconds() + * .resolution() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoProcessing = + VideoProcessing( + checkRequired("codec", codec), + checkRequired("durationSeconds", durationSeconds), + checkRequired("resolution", resolution), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws ImageKitInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): VideoProcessing = apply { + if (validated) { + return@apply + } + + codec() + durationSeconds() + resolution() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (codec.asKnown().isPresent) 1 else 0) + + (if (durationSeconds.asKnown().isPresent) 1 else 0) + + (if (resolution.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoProcessing && + codec == other.codec && + durationSeconds == other.durationSeconds && + resolution == other.resolution && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(codec, durationSeconds, resolution, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VideoProcessing{codec=$codec, durationSeconds=$durationSeconds, resolution=$resolution, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageAnalyticsResponse && + bandwidthBytes == other.bandwidthBytes && + browser == other.browser && + cache == other.cache && + country == other.country && + device == other.device && + endDate == other.endDate && + errorReasons == other.errorReasons && + extensions == other.extensions && + format == other.format && + generatedAt == other.generatedAt && + requestCount == other.requestCount && + startDate == other.startDate && + statusCodes == other.statusCodes && + top404Assets == other.top404Assets && + topImages == other.topImages && + topImageTransforms == other.topImageTransforms && + topOtherAssets == other.topOtherAssets && + topReferrers == other.topReferrers && + topUserAgents == other.topUserAgents && + topVideos == other.topVideos && + topVideoTransforms == other.topVideoTransforms && + urlEndpoints == other.urlEndpoints && + videoProcessing == other.videoProcessing && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bandwidthBytes, + browser, + cache, + country, + device, + endDate, + errorReasons, + extensions, + format, + generatedAt, + requestCount, + startDate, + statusCodes, + top404Assets, + topImages, + topImageTransforms, + topOtherAssets, + topReferrers, + topUserAgents, + topVideos, + topVideoTransforms, + urlEndpoints, + videoProcessing, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageAnalyticsResponse{bandwidthBytes=$bandwidthBytes, browser=$browser, cache=$cache, country=$country, device=$device, endDate=$endDate, errorReasons=$errorReasons, extensions=$extensions, format=$format, generatedAt=$generatedAt, requestCount=$requestCount, startDate=$startDate, statusCodes=$statusCodes, top404Assets=$top404Assets, topImages=$topImages, topImageTransforms=$topImageTransforms, topOtherAssets=$topOtherAssets, topReferrers=$topReferrers, topUserAgents=$topUserAgents, topVideos=$topVideos, topVideoTransforms=$topVideoTransforms, urlEndpoints=$urlEndpoints, videoProcessing=$videoProcessing, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt index 0eab4551..ea888902 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt @@ -5,6 +5,7 @@ package io.imagekit.services.async import io.imagekit.core.ClientOptions import io.imagekit.services.async.accounts.OriginServiceAsync import io.imagekit.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.services.async.accounts.UsageAnalyticsServiceAsync import io.imagekit.services.async.accounts.UsageServiceAsync import java.util.function.Consumer @@ -24,6 +25,8 @@ interface AccountServiceAsync { fun usage(): UsageServiceAsync + fun usageAnalytics(): UsageAnalyticsServiceAsync + fun origins(): OriginServiceAsync fun urlEndpoints(): UrlEndpointServiceAsync @@ -44,6 +47,8 @@ interface AccountServiceAsync { fun usage(): UsageServiceAsync.WithRawResponse + fun usageAnalytics(): UsageAnalyticsServiceAsync.WithRawResponse + fun origins(): OriginServiceAsync.WithRawResponse fun urlEndpoints(): UrlEndpointServiceAsync.WithRawResponse diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt index 77885c6e..cf5d6e4a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt @@ -7,6 +7,8 @@ import io.imagekit.services.async.accounts.OriginServiceAsync import io.imagekit.services.async.accounts.OriginServiceAsyncImpl import io.imagekit.services.async.accounts.UrlEndpointServiceAsync import io.imagekit.services.async.accounts.UrlEndpointServiceAsyncImpl +import io.imagekit.services.async.accounts.UsageAnalyticsServiceAsync +import io.imagekit.services.async.accounts.UsageAnalyticsServiceAsyncImpl import io.imagekit.services.async.accounts.UsageServiceAsync import io.imagekit.services.async.accounts.UsageServiceAsyncImpl import java.util.function.Consumer @@ -20,6 +22,10 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl private val usage: UsageServiceAsync by lazy { UsageServiceAsyncImpl(clientOptions) } + private val usageAnalytics: UsageAnalyticsServiceAsync by lazy { + UsageAnalyticsServiceAsyncImpl(clientOptions) + } + private val origins: OriginServiceAsync by lazy { OriginServiceAsyncImpl(clientOptions) } private val urlEndpoints: UrlEndpointServiceAsync by lazy { @@ -33,6 +39,8 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun usage(): UsageServiceAsync = usage + override fun usageAnalytics(): UsageAnalyticsServiceAsync = usageAnalytics + override fun origins(): OriginServiceAsync = origins override fun urlEndpoints(): UrlEndpointServiceAsync = urlEndpoints @@ -44,6 +52,10 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl UsageServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val usageAnalytics: UsageAnalyticsServiceAsync.WithRawResponse by lazy { + UsageAnalyticsServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val origins: OriginServiceAsync.WithRawResponse by lazy { OriginServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -61,6 +73,8 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun usage(): UsageServiceAsync.WithRawResponse = usage + override fun usageAnalytics(): UsageAnalyticsServiceAsync.WithRawResponse = usageAnalytics + override fun origins(): OriginServiceAsync.WithRawResponse = origins override fun urlEndpoints(): UrlEndpointServiceAsync.WithRawResponse = urlEndpoints diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsync.kt new file mode 100644 index 00000000..9e345e7f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsync.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.async.accounts + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsGetParams +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UsageAnalyticsServiceAsync { + + /** + * 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): UsageAnalyticsServiceAsync + + /** + * **Note:** This API is currently in beta. + * + * Get the account analytics data between two dates. The response covers the period from the + * start date to the end date, both dates inclusive. Both dates are interpreted as UTC calendar + * days. + * + * The returned data is scoped to the requesting account only. Unlike `/v1/accounts/usage`, an + * agency account's analytics are not aggregated across its child accounts. + * + * The response is cached for 5 minutes per account and date range. Use `generatedAt` to check + * how fresh the returned data is. + */ + fun get(params: UsageAnalyticsGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [UsageAnalyticsServiceAsync] 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 + ): UsageAnalyticsServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/accounts/usage-analytics`, but is otherwise the + * same as [UsageAnalyticsServiceAsync.get]. + */ + fun get( + params: UsageAnalyticsGetParams + ): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsyncImpl.kt new file mode 100644 index 00000000..a6683e32 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.async.accounts + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsGetParams +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class UsageAnalyticsServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : UsageAnalyticsServiceAsync { + + private val withRawResponse: UsageAnalyticsServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageAnalyticsServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): UsageAnalyticsServiceAsync = + UsageAnalyticsServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/accounts/usage-analytics + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageAnalyticsServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageAnalyticsServiceAsync.WithRawResponse = + UsageAnalyticsServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "usage-analytics") + .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 { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt index d91156df..16aee349 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt @@ -28,6 +28,11 @@ interface UsageServiceAsync { * Get the account usage information between two dates. Note that the API response includes data * from the start date while excluding data from the end date. In other words, the data covers * the period starting from the specified start date up to, but not including, the end date. + * + * For an agency account, the returned usage is aggregated across the agency and all of its + * child accounts that are billed to it. + * + * The response is cached for 6 hours per account, date range and requested metrics. */ fun get(params: UsageGetParams): CompletableFuture = get(params, RequestOptions.none()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt index e58140f1..bf31582b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt @@ -5,6 +5,7 @@ package io.imagekit.services.blocking import io.imagekit.core.ClientOptions import io.imagekit.services.blocking.accounts.OriginService import io.imagekit.services.blocking.accounts.UrlEndpointService +import io.imagekit.services.blocking.accounts.UsageAnalyticsService import io.imagekit.services.blocking.accounts.UsageService import java.util.function.Consumer @@ -24,6 +25,8 @@ interface AccountService { fun usage(): UsageService + fun usageAnalytics(): UsageAnalyticsService + fun origins(): OriginService fun urlEndpoints(): UrlEndpointService @@ -40,6 +43,8 @@ interface AccountService { fun usage(): UsageService.WithRawResponse + fun usageAnalytics(): UsageAnalyticsService.WithRawResponse + fun origins(): OriginService.WithRawResponse fun urlEndpoints(): UrlEndpointService.WithRawResponse diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt index d9a8800b..56a7d35c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt @@ -7,6 +7,8 @@ import io.imagekit.services.blocking.accounts.OriginService import io.imagekit.services.blocking.accounts.OriginServiceImpl import io.imagekit.services.blocking.accounts.UrlEndpointService import io.imagekit.services.blocking.accounts.UrlEndpointServiceImpl +import io.imagekit.services.blocking.accounts.UsageAnalyticsService +import io.imagekit.services.blocking.accounts.UsageAnalyticsServiceImpl import io.imagekit.services.blocking.accounts.UsageService import io.imagekit.services.blocking.accounts.UsageServiceImpl import java.util.function.Consumer @@ -20,6 +22,10 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO private val usage: UsageService by lazy { UsageServiceImpl(clientOptions) } + private val usageAnalytics: UsageAnalyticsService by lazy { + UsageAnalyticsServiceImpl(clientOptions) + } + private val origins: OriginService by lazy { OriginServiceImpl(clientOptions) } private val urlEndpoints: UrlEndpointService by lazy { UrlEndpointServiceImpl(clientOptions) } @@ -31,6 +37,8 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO override fun usage(): UsageService = usage + override fun usageAnalytics(): UsageAnalyticsService = usageAnalytics + override fun origins(): OriginService = origins override fun urlEndpoints(): UrlEndpointService = urlEndpoints @@ -42,6 +50,10 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO UsageServiceImpl.WithRawResponseImpl(clientOptions) } + private val usageAnalytics: UsageAnalyticsService.WithRawResponse by lazy { + UsageAnalyticsServiceImpl.WithRawResponseImpl(clientOptions) + } + private val origins: OriginService.WithRawResponse by lazy { OriginServiceImpl.WithRawResponseImpl(clientOptions) } @@ -59,6 +71,8 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO override fun usage(): UsageService.WithRawResponse = usage + override fun usageAnalytics(): UsageAnalyticsService.WithRawResponse = usageAnalytics + override fun origins(): OriginService.WithRawResponse = origins override fun urlEndpoints(): UrlEndpointService.WithRawResponse = urlEndpoints diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsService.kt new file mode 100644 index 00000000..f9cc0e60 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsService.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.blocking.accounts + +import com.google.errorprone.annotations.MustBeClosed +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsGetParams +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsResponse +import java.util.function.Consumer + +interface UsageAnalyticsService { + + /** + * 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): UsageAnalyticsService + + /** + * **Note:** This API is currently in beta. + * + * Get the account analytics data between two dates. The response covers the period from the + * start date to the end date, both dates inclusive. Both dates are interpreted as UTC calendar + * days. + * + * The returned data is scoped to the requesting account only. Unlike `/v1/accounts/usage`, an + * agency account's analytics are not aggregated across its child accounts. + * + * The response is cached for 5 minutes per account and date range. Use `generatedAt` to check + * how fresh the returned data is. + */ + fun get(params: UsageAnalyticsGetParams): UsageAnalyticsResponse = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UsageAnalyticsResponse + + /** + * A view of [UsageAnalyticsService] 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 + ): UsageAnalyticsService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/accounts/usage-analytics`, but is otherwise the + * same as [UsageAnalyticsService.get]. + */ + @MustBeClosed + fun get(params: UsageAnalyticsGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsServiceImpl.kt new file mode 100644 index 00000000..67f99dd8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.blocking.accounts + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsGetParams +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsResponse +import java.util.function.Consumer + +class UsageAnalyticsServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageAnalyticsService { + + private val withRawResponse: UsageAnalyticsService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageAnalyticsService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageAnalyticsService = + UsageAnalyticsServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions, + ): UsageAnalyticsResponse = + // get /v1/accounts/usage-analytics + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageAnalyticsService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageAnalyticsService.WithRawResponse = + UsageAnalyticsServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: UsageAnalyticsGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "usage-analytics") + .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 { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt index 62581a91..637bc5ab 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt @@ -28,6 +28,11 @@ interface UsageService { * Get the account usage information between two dates. Note that the API response includes data * from the start date while excluding data from the end date. In other words, the data covers * the period starting from the specified start date up to, but not including, the end date. + * + * For an agency account, the returned usage is aggregated across the agency and all of its + * child accounts that are billed to it. + * + * The response is cached for 6 hours per account, date range and requested metrics. */ fun get(params: UsageGetParams): UsageGetResponse = get(params, RequestOptions.none()) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/RequestBandwidthEntryTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/RequestBandwidthEntryTest.kt new file mode 100644 index 00000000..41d5fafd --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/RequestBandwidthEntryTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.accounts.usageanalytics + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import io.imagekit.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RequestBandwidthEntryTest { + + @Test + fun create() { + val requestBandwidthEntry = + RequestBandwidthEntry.builder().bandwidthBytes(0.0).requestCount(0.0).build() + + assertThat(requestBandwidthEntry.bandwidthBytes()).isEqualTo(0.0) + assertThat(requestBandwidthEntry.requestCount()).isEqualTo(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val requestBandwidthEntry = + RequestBandwidthEntry.builder().bandwidthBytes(0.0).requestCount(0.0).build() + + val roundtrippedRequestBandwidthEntry = + jsonMapper.readValue( + jsonMapper.writeValueAsString(requestBandwidthEntry), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRequestBandwidthEntry).isEqualTo(requestBandwidthEntry) + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsGetParamsTest.kt new file mode 100644 index 00000000..bdd095b1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsGetParamsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.accounts.usageanalytics + +import io.imagekit.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageAnalyticsGetParamsTest { + + @Test + fun create() { + UsageAnalyticsGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun queryParams() { + val params = + UsageAnalyticsGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("endDate", "2019-12-27") + .put("startDate", "2019-12-27") + .build() + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsResponseTest.kt new file mode 100644 index 00000000..cc51c178 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usageanalytics/UsageAnalyticsResponseTest.kt @@ -0,0 +1,836 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.accounts.usageanalytics + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import io.imagekit.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageAnalyticsResponseTest { + + @Test + fun create() { + val usageAnalyticsResponse = + UsageAnalyticsResponse.builder() + .bandwidthBytes(0.0) + .browser( + UsageAnalyticsResponse.Browser.builder() + .addByBandwidth( + UsageAnalyticsResponse.Browser.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Browser.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .cache( + UsageAnalyticsResponse.Cache.builder() + .errorCount(0.0) + .hitCount(0.0) + .missCount(0.0) + .build() + ) + .country( + UsageAnalyticsResponse.Country.builder() + .addByBandwidth( + UsageAnalyticsResponse.Country.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .code("code") + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Country.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .code("code") + .name("name") + .build() + ) + .build() + ) + .device( + UsageAnalyticsResponse.Device.builder() + .addByBandwidth( + UsageAnalyticsResponse.Device.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Device.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .endDate(LocalDate.parse("2019-12-27")) + .addErrorReason( + UsageAnalyticsResponse.ErrorReason.builder() + .name("ENOENT - Resource not found at any upstream origin") + .requestCount(0.0) + .build() + ) + .addExtension( + UsageAnalyticsResponse.Extension.builder() + .name("remove-bg") + .operationCount(0.0) + .build() + ) + .format( + UsageAnalyticsResponse.Format.builder() + .addByBandwidth( + UsageAnalyticsResponse.Format.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Format.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .generatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .requestCount(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .addStatusCode( + UsageAnalyticsResponse.StatusCode.builder() + .name("200") + .requestCount(0.0) + .build() + ) + .addTop404Asset( + UsageAnalyticsResponse.Top404Asset.builder() + .name("https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg") + .requestCount(0.0) + .build() + ) + .topImages( + UsageAnalyticsResponse.TopImages.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopImages.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopImages.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topImageTransforms( + UsageAnalyticsResponse.TopImageTransforms.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopImageTransforms.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopImageTransforms.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topOtherAssets( + UsageAnalyticsResponse.TopOtherAssets.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopOtherAssets.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopOtherAssets.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topReferrers( + UsageAnalyticsResponse.TopReferrers.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopReferrers.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopReferrers.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topUserAgents( + UsageAnalyticsResponse.TopUserAgents.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopUserAgents.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopUserAgents.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topVideos( + UsageAnalyticsResponse.TopVideos.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopVideos.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopVideos.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topVideoTransforms( + UsageAnalyticsResponse.TopVideoTransforms.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopVideoTransforms.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopVideoTransforms.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .urlEndpoints( + UsageAnalyticsResponse.UrlEndpoints.builder() + .addByBandwidth( + UsageAnalyticsResponse.UrlEndpoints.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.UrlEndpoints.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .addVideoProcessing( + UsageAnalyticsResponse.VideoProcessing.builder() + .codec("codec") + .durationSeconds(0.0) + .resolution("resolution") + .build() + ) + .build() + + assertThat(usageAnalyticsResponse.bandwidthBytes()).isEqualTo(0.0) + assertThat(usageAnalyticsResponse.browser()) + .isEqualTo( + UsageAnalyticsResponse.Browser.builder() + .addByBandwidth( + UsageAnalyticsResponse.Browser.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Browser.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.cache()) + .isEqualTo( + UsageAnalyticsResponse.Cache.builder() + .errorCount(0.0) + .hitCount(0.0) + .missCount(0.0) + .build() + ) + assertThat(usageAnalyticsResponse.country()) + .isEqualTo( + UsageAnalyticsResponse.Country.builder() + .addByBandwidth( + UsageAnalyticsResponse.Country.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .code("code") + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Country.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .code("code") + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.device()) + .isEqualTo( + UsageAnalyticsResponse.Device.builder() + .addByBandwidth( + UsageAnalyticsResponse.Device.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Device.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.endDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(usageAnalyticsResponse.errorReasons()) + .containsExactly( + UsageAnalyticsResponse.ErrorReason.builder() + .name("ENOENT - Resource not found at any upstream origin") + .requestCount(0.0) + .build() + ) + assertThat(usageAnalyticsResponse.extensions()) + .containsExactly( + UsageAnalyticsResponse.Extension.builder() + .name("remove-bg") + .operationCount(0.0) + .build() + ) + assertThat(usageAnalyticsResponse.format()) + .isEqualTo( + UsageAnalyticsResponse.Format.builder() + .addByBandwidth( + UsageAnalyticsResponse.Format.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Format.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.generatedAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(usageAnalyticsResponse.requestCount()).isEqualTo(0.0) + assertThat(usageAnalyticsResponse.startDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(usageAnalyticsResponse.statusCodes()) + .containsExactly( + UsageAnalyticsResponse.StatusCode.builder().name("200").requestCount(0.0).build() + ) + assertThat(usageAnalyticsResponse.top404Assets()) + .containsExactly( + UsageAnalyticsResponse.Top404Asset.builder() + .name("https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg") + .requestCount(0.0) + .build() + ) + assertThat(usageAnalyticsResponse.topImages()) + .isEqualTo( + UsageAnalyticsResponse.TopImages.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopImages.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopImages.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.topImageTransforms()) + .isEqualTo( + UsageAnalyticsResponse.TopImageTransforms.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopImageTransforms.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopImageTransforms.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.topOtherAssets()) + .isEqualTo( + UsageAnalyticsResponse.TopOtherAssets.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopOtherAssets.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopOtherAssets.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.topReferrers()) + .isEqualTo( + UsageAnalyticsResponse.TopReferrers.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopReferrers.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopReferrers.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.topUserAgents()) + .isEqualTo( + UsageAnalyticsResponse.TopUserAgents.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopUserAgents.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopUserAgents.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.topVideos()) + .isEqualTo( + UsageAnalyticsResponse.TopVideos.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopVideos.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopVideos.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.topVideoTransforms()) + .isEqualTo( + UsageAnalyticsResponse.TopVideoTransforms.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopVideoTransforms.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopVideoTransforms.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.urlEndpoints()) + .isEqualTo( + UsageAnalyticsResponse.UrlEndpoints.builder() + .addByBandwidth( + UsageAnalyticsResponse.UrlEndpoints.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.UrlEndpoints.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + assertThat(usageAnalyticsResponse.videoProcessing()) + .containsExactly( + UsageAnalyticsResponse.VideoProcessing.builder() + .codec("codec") + .durationSeconds(0.0) + .resolution("resolution") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val usageAnalyticsResponse = + UsageAnalyticsResponse.builder() + .bandwidthBytes(0.0) + .browser( + UsageAnalyticsResponse.Browser.builder() + .addByBandwidth( + UsageAnalyticsResponse.Browser.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Browser.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .cache( + UsageAnalyticsResponse.Cache.builder() + .errorCount(0.0) + .hitCount(0.0) + .missCount(0.0) + .build() + ) + .country( + UsageAnalyticsResponse.Country.builder() + .addByBandwidth( + UsageAnalyticsResponse.Country.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .code("code") + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Country.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .code("code") + .name("name") + .build() + ) + .build() + ) + .device( + UsageAnalyticsResponse.Device.builder() + .addByBandwidth( + UsageAnalyticsResponse.Device.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Device.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .endDate(LocalDate.parse("2019-12-27")) + .addErrorReason( + UsageAnalyticsResponse.ErrorReason.builder() + .name("ENOENT - Resource not found at any upstream origin") + .requestCount(0.0) + .build() + ) + .addExtension( + UsageAnalyticsResponse.Extension.builder() + .name("remove-bg") + .operationCount(0.0) + .build() + ) + .format( + UsageAnalyticsResponse.Format.builder() + .addByBandwidth( + UsageAnalyticsResponse.Format.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.Format.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .generatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .requestCount(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .addStatusCode( + UsageAnalyticsResponse.StatusCode.builder() + .name("200") + .requestCount(0.0) + .build() + ) + .addTop404Asset( + UsageAnalyticsResponse.Top404Asset.builder() + .name("https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg") + .requestCount(0.0) + .build() + ) + .topImages( + UsageAnalyticsResponse.TopImages.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopImages.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopImages.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topImageTransforms( + UsageAnalyticsResponse.TopImageTransforms.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopImageTransforms.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopImageTransforms.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topOtherAssets( + UsageAnalyticsResponse.TopOtherAssets.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopOtherAssets.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopOtherAssets.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topReferrers( + UsageAnalyticsResponse.TopReferrers.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopReferrers.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopReferrers.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topUserAgents( + UsageAnalyticsResponse.TopUserAgents.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopUserAgents.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopUserAgents.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topVideos( + UsageAnalyticsResponse.TopVideos.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopVideos.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopVideos.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .topVideoTransforms( + UsageAnalyticsResponse.TopVideoTransforms.builder() + .addByBandwidth( + UsageAnalyticsResponse.TopVideoTransforms.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.TopVideoTransforms.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .urlEndpoints( + UsageAnalyticsResponse.UrlEndpoints.builder() + .addByBandwidth( + UsageAnalyticsResponse.UrlEndpoints.ByBandwidth.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .addByRequest( + UsageAnalyticsResponse.UrlEndpoints.ByRequest.builder() + .bandwidthBytes(0.0) + .requestCount(0.0) + .name("name") + .build() + ) + .build() + ) + .addVideoProcessing( + UsageAnalyticsResponse.VideoProcessing.builder() + .codec("codec") + .durationSeconds(0.0) + .resolution("resolution") + .build() + ) + .build() + + val roundtrippedUsageAnalyticsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(usageAnalyticsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUsageAnalyticsResponse).isEqualTo(usageAnalyticsResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsyncTest.kt new file mode 100644 index 00000000..8f18090b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UsageAnalyticsServiceAsyncTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.async.accounts + +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsGetParams +import java.time.LocalDate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class UsageAnalyticsServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val usageAnalyticsServiceAsync = client.accounts().usageAnalytics() + + val usageAnalyticsResponseFuture = + usageAnalyticsServiceAsync.get( + UsageAnalyticsGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val usageAnalyticsResponse = usageAnalyticsResponseFuture.get() + usageAnalyticsResponse.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsServiceTest.kt new file mode 100644 index 00000000..be3b1ff7 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UsageAnalyticsServiceTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.blocking.accounts + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.accounts.usageanalytics.UsageAnalyticsGetParams +import java.time.LocalDate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class UsageAnalyticsServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val usageAnalyticsService = client.accounts().usageAnalytics() + + val usageAnalyticsResponse = + usageAnalyticsService.get( + UsageAnalyticsGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + usageAnalyticsResponse.validate() + } +}