From 4e465d8dc92b56181a575bfc0c4c619b61ce81df Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Wed, 29 Jul 2026 07:46:24 +0000 Subject: [PATCH 01/10] Build SDK Stainless-Generated-From: 40f0981b008b019395cbb8abe7681861226d5af9 --- .stats.yml | 2 +- .../io/imagekit/client/ImageKitClient.kt | 5 + .../io/imagekit/client/ImageKitClientAsync.kt | 5 + .../client/ImageKitClientAsyncImpl.kt | 15 + .../io/imagekit/client/ImageKitClientImpl.kt | 15 + .../io/imagekit/models/NamedTransformation.kt | 330 ++++++++++ .../NamedTransformationCreateParams.kt | 623 ++++++++++++++++++ .../NamedTransformationDeleteParams.kt | 245 +++++++ .../NamedTransformationGetParams.kt | 195 ++++++ .../NamedTransformationListParams.kt | 173 +++++ .../NamedTransformationUpdateParams.kt | 581 ++++++++++++++++ .../async/NamedTransformationServiceAsync.kt | 357 ++++++++++ .../NamedTransformationServiceAsyncImpl.kt | 256 +++++++ .../blocking/NamedTransformationService.kt | 357 ++++++++++ .../NamedTransformationServiceImpl.kt | 237 +++++++ .../models/NamedTransformationTest.kt | 53 ++ .../NamedTransformationCreateParamsTest.kt | 48 ++ .../NamedTransformationDeleteParamsTest.kt | 23 + .../NamedTransformationGetParamsTest.kt | 23 + .../NamedTransformationListParamsTest.kt | 13 + .../NamedTransformationUpdateParamsTest.kt | 52 ++ .../NamedTransformationServiceAsyncTest.kt | 107 +++ .../NamedTransformationServiceTest.kt | 102 +++ .../proguard/ProGuardCompatibilityTest.kt | 1 + 24 files changed, 3817 insertions(+), 1 deletion(-) create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 58526a77..847bd32c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 48 +configured_endpoints: 53 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt index 9a3a74ca..6f7c894e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt @@ -11,6 +11,7 @@ import io.imagekit.services.blocking.CacheService import io.imagekit.services.blocking.CustomMetadataFieldService import io.imagekit.services.blocking.FileService import io.imagekit.services.blocking.FolderService +import io.imagekit.services.blocking.NamedTransformationService import io.imagekit.services.blocking.SavedExtensionService import io.imagekit.services.blocking.WebhookService import java.util.function.Consumer @@ -57,6 +58,8 @@ interface ImageKitClient { fun savedExtensions(): SavedExtensionService + fun namedTransformations(): NamedTransformationService + fun assets(): AssetService fun cache(): CacheService @@ -100,6 +103,8 @@ interface ImageKitClient { fun savedExtensions(): SavedExtensionService.WithRawResponse + fun namedTransformations(): NamedTransformationService.WithRawResponse + fun assets(): AssetService.WithRawResponse fun cache(): CacheService.WithRawResponse diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt index cba5ce63..32a4b914 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt @@ -11,6 +11,7 @@ import io.imagekit.services.async.CacheServiceAsync import io.imagekit.services.async.CustomMetadataFieldServiceAsync import io.imagekit.services.async.FileServiceAsync import io.imagekit.services.async.FolderServiceAsync +import io.imagekit.services.async.NamedTransformationServiceAsync import io.imagekit.services.async.SavedExtensionServiceAsync import io.imagekit.services.async.WebhookServiceAsync import java.util.function.Consumer @@ -57,6 +58,8 @@ interface ImageKitClientAsync { fun savedExtensions(): SavedExtensionServiceAsync + fun namedTransformations(): NamedTransformationServiceAsync + fun assets(): AssetServiceAsync fun cache(): CacheServiceAsync @@ -104,6 +107,8 @@ interface ImageKitClientAsync { fun savedExtensions(): SavedExtensionServiceAsync.WithRawResponse + fun namedTransformations(): NamedTransformationServiceAsync.WithRawResponse + fun assets(): AssetServiceAsync.WithRawResponse fun cache(): CacheServiceAsync.WithRawResponse diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt index ef9cab34..64820aeb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt @@ -20,6 +20,8 @@ import io.imagekit.services.async.FileServiceAsync import io.imagekit.services.async.FileServiceAsyncImpl import io.imagekit.services.async.FolderServiceAsync import io.imagekit.services.async.FolderServiceAsyncImpl +import io.imagekit.services.async.NamedTransformationServiceAsync +import io.imagekit.services.async.NamedTransformationServiceAsyncImpl import io.imagekit.services.async.SavedExtensionServiceAsync import io.imagekit.services.async.SavedExtensionServiceAsyncImpl import io.imagekit.services.async.WebhookServiceAsync @@ -53,6 +55,10 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK SavedExtensionServiceAsyncImpl(clientOptionsWithUserAgent) } + private val namedTransformations: NamedTransformationServiceAsync by lazy { + NamedTransformationServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val assets: AssetServiceAsync by lazy { AssetServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -90,6 +96,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun savedExtensions(): SavedExtensionServiceAsync = savedExtensions + override fun namedTransformations(): NamedTransformationServiceAsync = namedTransformations + override fun assets(): AssetServiceAsync = assets override fun cache(): CacheServiceAsync = cache @@ -121,6 +129,10 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK SavedExtensionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val namedTransformations: NamedTransformationServiceAsync.WithRawResponse by lazy { + NamedTransformationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val assets: AssetServiceAsync.WithRawResponse by lazy { AssetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -159,6 +171,9 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun savedExtensions(): SavedExtensionServiceAsync.WithRawResponse = savedExtensions + override fun namedTransformations(): NamedTransformationServiceAsync.WithRawResponse = + namedTransformations + override fun assets(): AssetServiceAsync.WithRawResponse = assets override fun cache(): CacheServiceAsync.WithRawResponse = cache diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt index b8deaa48..bcf8712f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt @@ -20,6 +20,8 @@ import io.imagekit.services.blocking.FileService import io.imagekit.services.blocking.FileServiceImpl import io.imagekit.services.blocking.FolderService import io.imagekit.services.blocking.FolderServiceImpl +import io.imagekit.services.blocking.NamedTransformationService +import io.imagekit.services.blocking.NamedTransformationServiceImpl import io.imagekit.services.blocking.SavedExtensionService import io.imagekit.services.blocking.SavedExtensionServiceImpl import io.imagekit.services.blocking.WebhookService @@ -53,6 +55,10 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli SavedExtensionServiceImpl(clientOptionsWithUserAgent) } + private val namedTransformations: NamedTransformationService by lazy { + NamedTransformationServiceImpl(clientOptionsWithUserAgent) + } + private val assets: AssetService by lazy { AssetServiceImpl(clientOptionsWithUserAgent) } private val cache: CacheService by lazy { CacheServiceImpl(clientOptionsWithUserAgent) } @@ -80,6 +86,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun savedExtensions(): SavedExtensionService = savedExtensions + override fun namedTransformations(): NamedTransformationService = namedTransformations + override fun assets(): AssetService = assets override fun cache(): CacheService = cache @@ -111,6 +119,10 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli SavedExtensionServiceImpl.WithRawResponseImpl(clientOptions) } + private val namedTransformations: NamedTransformationService.WithRawResponse by lazy { + NamedTransformationServiceImpl.WithRawResponseImpl(clientOptions) + } + private val assets: AssetService.WithRawResponse by lazy { AssetServiceImpl.WithRawResponseImpl(clientOptions) } @@ -149,6 +161,9 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun savedExtensions(): SavedExtensionService.WithRawResponse = savedExtensions + override fun namedTransformations(): NamedTransformationService.WithRawResponse = + namedTransformations + override fun assets(): AssetService.WithRawResponse = assets override fun cache(): CacheService.WithRawResponse = cache diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt new file mode 100644 index 00000000..fb08503c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -0,0 +1,330 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * A named transformation is an alias for an actual transformation string, allowing you to apply and + * later update complex transformations without changing your image or video URLs. Learn more about + * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ +class NamedTransformation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val disabled: JsonField, + private val name: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("disabled") @ExcludeMissing disabled: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(id, createdAt, disabled, name, transformation, mutableMapOf()) + + /** + * Unique identifier of the named transformation. This is generated by ImageKit when you create + * a new named transformation. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Timestamp when the named transformation was created. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("createdAt") + + /** + * Whether this named transformation is currently disabled. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun disabled(): Optional = disabled.getOptional("disabled") + + /** + * Name of the named transformation, used as `tr:n-` in image and video URLs. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The transformation string this name refers to. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transformation(): Optional = transformation.getOptional("transformation") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + + /** + * 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 [transformation]. + * + * Unlike [transformation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): JsonField = transformation + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [NamedTransformation]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformation]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var disabled: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var transformation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(namedTransformation: NamedTransformation) = apply { + id = namedTransformation.id + createdAt = namedTransformation.createdAt + disabled = namedTransformation.disabled + name = namedTransformation.name + transformation = namedTransformation.transformation + additionalProperties = namedTransformation.additionalProperties.toMutableMap() + } + + /** + * Unique identifier of the named transformation. This is generated by ImageKit when you + * create a new named transformation. + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp when the named transformation was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Whether this named transformation is currently disabled. */ + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + + /** Name of the named transformation, used as `tr:n-` in image and video URLs. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The transformation string this name refers to. */ + fun transformation(transformation: String) = transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: JsonField) = apply { + this.transformation = transformation + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NamedTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NamedTransformation = + NamedTransformation( + id, + createdAt, + disabled, + name, + transformation, + 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(): NamedTransformation = apply { + if (validated) { + return@apply + } + + id() + createdAt() + disabled() + name() + transformation() + 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 (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (disabled.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (transformation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformation && + id == other.id && + createdAt == other.createdAt && + disabled == other.disabled && + name == other.name && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, disabled, name, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NamedTransformation{id=$id, createdAt=$createdAt, disabled=$disabled, name=$name, transformation=$transformation, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt new file mode 100644 index 00000000..68b0df66 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -0,0 +1,623 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +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.Params +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Creates a new named transformation and returns the created object. + * + * Named transformations let you assign a short, reusable name to a complex transformation string, + * so it can be applied in image and video URLs as `tr:n-` and later updated without changing + * any existing URLs. + * + * Learn more about + * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ +class NamedTransformationCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Name of the named transformation. This is the alias used to refer to the transformation + * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric + * characters, `_` and `-`, and must be unique for your account (case-insensitive). + * + * @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 = body.name() + + /** + * The transformation string this name refers to. It must start with `tr:` followed by one or + * more transformation parameters, for example `tr:w-150,h-150,fo-center,cm-resize`. Learn more + * about the [transformation syntax](https://imagekit.io/docs/transformations). + * + * @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 transformation(): String = body.transformation() + + /** + * Whether this named transformation is disabled. Set to `true` to temporarily disable it + * without deleting it — requests using a disabled named transformation fail at delivery time. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun disabled(): Optional = body.disabled() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transformation(): JsonField = body._transformation() + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _disabled(): JsonField = body._disabled() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NamedTransformationCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .transformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformationCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(namedTransformationCreateParams: NamedTransformationCreateParams) = + apply { + body = namedTransformationCreateParams.body.toBuilder() + additionalHeaders = namedTransformationCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = + namedTransformationCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [transformation] + * - [disabled] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Name of the named transformation. This is the alias used to refer to the transformation + * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric + * characters, `_` and `-`, and must be unique for your account (case-insensitive). + */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * The transformation string this name refers to. It must start with `tr:` followed by one + * or more transformation parameters, for example `tr:w-150,h-150,fo-center,cm-resize`. + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + */ + fun transformation(transformation: String) = apply { body.transformation(transformation) } + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: JsonField) = apply { + body.transformation(transformation) + } + + /** + * Whether this named transformation is disabled. Set to `true` to temporarily disable it + * without deleting it — requests using a disabled named transformation fail at delivery + * time. + */ + fun disabled(disabled: Boolean) = apply { body.disabled(disabled) } + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disabled(disabled: JsonField) = apply { body.disabled(disabled) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NamedTransformationCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NamedTransformationCreateParams = + NamedTransformationCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val transformation: JsonField, + private val disabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("disabled") + @ExcludeMissing + disabled: JsonField = JsonMissing.of(), + ) : this(name, transformation, disabled, mutableMapOf()) + + /** + * Name of the named transformation. This is the alias used to refer to the transformation + * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric + * characters, `_` and `-`, and must be unique for your account (case-insensitive). + * + * @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") + + /** + * The transformation string this name refers to. It must start with `tr:` followed by one + * or more transformation parameters, for example `tr:w-150,h-150,fo-center,cm-resize`. + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * + * @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 transformation(): String = transformation.getRequired("transformation") + + /** + * Whether this named transformation is disabled. Set to `true` to temporarily disable it + * without deleting it — requests using a disabled named transformation fail at delivery + * time. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun disabled(): Optional = disabled.getOptional("disabled") + + /** + * 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 [transformation]. + * + * Unlike [transformation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): JsonField = transformation + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .transformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var transformation: JsonField? = null + private var disabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + transformation = body.transformation + disabled = body.disabled + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Name of the named transformation. This is the alias used to refer to the + * transformation string in image and video URLs, for example `tr:n-`. Can only + * contain alphanumeric characters, `_` and `-`, and must be unique for your account + * (case-insensitive). + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The transformation string this name refers to. It must start with `tr:` followed by + * one or more transformation parameters, for example + * `tr:w-150,h-150,fo-center,cm-resize`. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). + */ + fun transformation(transformation: String) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: JsonField) = apply { + this.transformation = transformation + } + + /** + * Whether this named transformation is disabled. Set to `true` to temporarily disable + * it without deleting it — requests using a disabled named transformation fail at + * delivery time. + */ + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + checkRequired("transformation", transformation), + disabled, + 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(): Body = apply { + if (validated) { + return@apply + } + + name() + transformation() + disabled() + 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 (transformation.asKnown().isPresent) 1 else 0) + + (if (disabled.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + transformation == other.transformation && + disabled == other.disabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, transformation, disabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, transformation=$transformation, disabled=$disabled, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformationCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "NamedTransformationCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt new file mode 100644 index 00000000..b1f753ae --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import io.imagekit.core.JsonValue +import io.imagekit.core.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Permanently deletes the named transformation identified by `id` and returns the deleted object. + * + * **Note:** + * - If another named transformation, or your account's upload + * pre-transformation/post-transformation settings, reference this named transformation (via the + * `n-` token), the request fails with a `409` error and the response body includes a + * `references` array describing where it is used. Remove those references first, then retry the + * deletion. This is a best-effort check and cannot detect references baked into your own + * application code or previously generated URLs. + */ +class NamedTransformationDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NamedTransformationDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [NamedTransformationDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformationDeleteParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(namedTransformationDeleteParams: NamedTransformationDeleteParams) = + apply { + id = namedTransformationDeleteParams.id + additionalHeaders = namedTransformationDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = + namedTransformationDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + namedTransformationDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [NamedTransformationDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NamedTransformationDeleteParams = + NamedTransformationDeleteParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformationDeleteParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "NamedTransformationDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt new file mode 100644 index 00000000..cb89808c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import io.imagekit.core.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieves the named transformation identified by `id`. */ +class NamedTransformationGetParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NamedTransformationGetParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [NamedTransformationGetParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformationGetParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(namedTransformationGetParams: NamedTransformationGetParams) = apply { + id = namedTransformationGetParams.id + additionalHeaders = namedTransformationGetParams.additionalHeaders.toBuilder() + additionalQueryParams = namedTransformationGetParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NamedTransformationGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NamedTransformationGetParams = + NamedTransformationGetParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformationGetParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "NamedTransformationGetParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParams.kt new file mode 100644 index 00000000..0c1882ba --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParams.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import io.imagekit.core.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import java.util.Objects + +/** Returns an array of all named transformations configured for your account. */ +class NamedTransformationListParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NamedTransformationListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [NamedTransformationListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformationListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(namedTransformationListParams: NamedTransformationListParams) = apply { + additionalHeaders = namedTransformationListParams.additionalHeaders.toBuilder() + additionalQueryParams = namedTransformationListParams.additionalQueryParams.toBuilder() + } + + 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 [NamedTransformationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NamedTransformationListParams = + NamedTransformationListParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformationListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "NamedTransformationListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt new file mode 100644 index 00000000..c439c4f3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -0,0 +1,581 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +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.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Updates the named transformation identified by `id` and returns the updated object. Only the + * fields present in the request body are updated; omitted fields are left unchanged. + */ +class NamedTransformationUpdateParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * Whether this named transformation is disabled. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun disabled(): Optional = body.disabled() + + /** + * Updated name of the named transformation. Can only contain alphanumeric characters, `_` and + * `-`, and must be unique for your account (case-insensitive). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * Updated transformation string. It must start with `tr:` followed by one or more + * transformation parameters. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transformation(): Optional = body.transformation() + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _disabled(): JsonField = body._disabled() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transformation(): JsonField = body._transformation() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NamedTransformationUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [NamedTransformationUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformationUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(namedTransformationUpdateParams: NamedTransformationUpdateParams) = + apply { + id = namedTransformationUpdateParams.id + body = namedTransformationUpdateParams.body.toBuilder() + additionalHeaders = namedTransformationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = + namedTransformationUpdateParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [disabled] + * - [name] + * - [transformation] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Whether this named transformation is disabled. */ + fun disabled(disabled: Boolean) = apply { body.disabled(disabled) } + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disabled(disabled: JsonField) = apply { body.disabled(disabled) } + + /** + * Updated name of the named transformation. Can only contain alphanumeric characters, `_` + * and `-`, and must be unique for your account (case-insensitive). + */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * Updated transformation string. It must start with `tr:` followed by one or more + * transformation parameters. + */ + fun transformation(transformation: String) = apply { body.transformation(transformation) } + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: JsonField) = apply { + body.transformation(transformation) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NamedTransformationUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NamedTransformationUpdateParams = + NamedTransformationUpdateParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val disabled: JsonField, + private val name: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("disabled") + @ExcludeMissing + disabled: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(disabled, name, transformation, mutableMapOf()) + + /** + * Whether this named transformation is disabled. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun disabled(): Optional = disabled.getOptional("disabled") + + /** + * Updated name of the named transformation. Can only contain alphanumeric characters, `_` + * and `-`, and must be unique for your account (case-insensitive). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Updated transformation string. It must start with `tr:` followed by one or more + * transformation parameters. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformation(): Optional = transformation.getOptional("transformation") + + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + + /** + * 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 [transformation]. + * + * Unlike [transformation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): JsonField = transformation + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var disabled: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var transformation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + disabled = body.disabled + name = body.name + transformation = body.transformation + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Whether this named transformation is disabled. */ + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + + /** + * Updated name of the named transformation. Can only contain alphanumeric characters, + * `_` and `-`, and must be unique for your account (case-insensitive). + */ + 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 } + + /** + * Updated transformation string. It must start with `tr:` followed by one or more + * transformation parameters. + */ + fun transformation(transformation: String) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: JsonField) = apply { + this.transformation = transformation + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body(disabled, name, transformation, 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(): Body = apply { + if (validated) { + return@apply + } + + disabled() + name() + transformation() + 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 (disabled.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (transformation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + disabled == other.disabled && + name == other.name && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(disabled, name, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{disabled=$disabled, name=$name, transformation=$transformation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformationUpdateParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "NamedTransformationUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt new file mode 100644 index 00000000..565232c4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -0,0 +1,357 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.NamedTransformation +import io.imagekit.models.namedtransformations.NamedTransformationCreateParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationGetParams +import io.imagekit.models.namedtransformations.NamedTransformationListParams +import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface NamedTransformationServiceAsync { + + /** + * 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): NamedTransformationServiceAsync + + /** + * Creates a new named transformation and returns the created object. + * + * Named transformations let you assign a short, reusable name to a complex transformation + * string, so it can be applied in image and video URLs as `tr:n-` and later updated + * without changing any existing URLs. + * + * Learn more about + * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ + fun create(params: NamedTransformationCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Updates the named transformation identified by `id` and returns the updated object. Only the + * fields present in the request body are updated; omitted fields are left unchanged. + */ + fun update(id: String): CompletableFuture = + update(id, NamedTransformationUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + ): CompletableFuture = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: NamedTransformationUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): CompletableFuture = + update(id, NamedTransformationUpdateParams.none(), requestOptions) + + /** Returns an array of all named transformations configured for your account. */ + fun list(): CompletableFuture> = + list(NamedTransformationListParams.none()) + + /** @see list */ + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(NamedTransformationListParams.none(), requestOptions) + + /** + * Permanently deletes the named transformation identified by `id` and returns the deleted + * object. + * + * **Note:** + * - If another named transformation, or your account's upload + * pre-transformation/post-transformation settings, reference this named transformation (via + * the `n-` token), the request fails with a `409` error and the response body includes + * a `references` array describing where it is used. Remove those references first, then retry + * the deletion. This is a best-effort check and cannot detect references baked into your own + * application code or previously generated URLs. + */ + fun delete(id: String): CompletableFuture = + delete(id, NamedTransformationDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: NamedTransformationDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, NamedTransformationDeleteParams.none(), requestOptions) + + /** Retrieves the named transformation identified by `id`. */ + fun get(id: String): CompletableFuture = + get(id, NamedTransformationGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + ): CompletableFuture = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: NamedTransformationGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + get(id, NamedTransformationGetParams.none(), requestOptions) + + /** + * A view of [NamedTransformationServiceAsync] 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 + ): NamedTransformationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/named-transformations`, but is otherwise the + * same as [NamedTransformationServiceAsync.create]. + */ + fun create( + params: NamedTransformationCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/named-transformations/{id}`, but is otherwise + * the same as [NamedTransformationServiceAsync.update]. + */ + fun update(id: String): CompletableFuture> = + update(id, NamedTransformationUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + ): CompletableFuture> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: NamedTransformationUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(id, NamedTransformationUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/named-transformations`, but is otherwise the + * same as [NamedTransformationServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(NamedTransformationListParams.none()) + + /** @see list */ + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(NamedTransformationListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/named-transformations/{id}`, but is otherwise + * the same as [NamedTransformationServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture> = + delete(id, NamedTransformationDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + ): CompletableFuture> = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see delete */ + fun delete( + params: NamedTransformationDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(id, NamedTransformationDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/named-transformations/{id}`, but is otherwise + * the same as [NamedTransformationServiceAsync.get]. + */ + fun get(id: String): CompletableFuture> = + get(id, NamedTransformationGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + ): CompletableFuture> = + get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get( + params: NamedTransformationGetParams + ): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(id, NamedTransformationGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt new file mode 100644 index 00000000..435db72b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +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.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.NamedTransformation +import io.imagekit.models.namedtransformations.NamedTransformationCreateParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationGetParams +import io.imagekit.models.namedtransformations.NamedTransformationListParams +import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class NamedTransformationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : NamedTransformationServiceAsync { + + private val withRawResponse: NamedTransformationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): NamedTransformationServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): NamedTransformationServiceAsync = + NamedTransformationServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/named-transformations + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /v1/named-transformations/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: NamedTransformationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/named-transformations + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/named-transformations/{id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/named-transformations/{id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NamedTransformationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): NamedTransformationServiceAsync.WithRawResponse = + NamedTransformationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: NamedTransformationListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .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 { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt new file mode 100644 index 00000000..36790a70 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -0,0 +1,357 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.blocking + +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.NamedTransformation +import io.imagekit.models.namedtransformations.NamedTransformationCreateParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationGetParams +import io.imagekit.models.namedtransformations.NamedTransformationListParams +import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams +import java.util.function.Consumer + +interface NamedTransformationService { + + /** + * 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): NamedTransformationService + + /** + * Creates a new named transformation and returns the created object. + * + * Named transformations let you assign a short, reusable name to a complex transformation + * string, so it can be applied in image and video URLs as `tr:n-` and later updated + * without changing any existing URLs. + * + * Learn more about + * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ + fun create(params: NamedTransformationCreateParams): NamedTransformation = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation + + /** + * Updates the named transformation identified by `id` and returns the updated object. Only the + * fields present in the request body are updated; omitted fields are left unchanged. + */ + fun update(id: String): NamedTransformation = update(id, NamedTransformationUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + ): NamedTransformation = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation + + /** @see update */ + fun update(params: NamedTransformationUpdateParams): NamedTransformation = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): NamedTransformation = + update(id, NamedTransformationUpdateParams.none(), requestOptions) + + /** Returns an array of all named transformations configured for your account. */ + fun list(): List = list(NamedTransformationListParams.none()) + + /** @see list */ + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none() + ): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(NamedTransformationListParams.none(), requestOptions) + + /** + * Permanently deletes the named transformation identified by `id` and returns the deleted + * object. + * + * **Note:** + * - If another named transformation, or your account's upload + * pre-transformation/post-transformation settings, reference this named transformation (via + * the `n-` token), the request fails with a `409` error and the response body includes + * a `references` array describing where it is used. Remove those references first, then retry + * the deletion. This is a best-effort check and cannot detect references baked into your own + * application code or previously generated URLs. + */ + fun delete(id: String): NamedTransformation = delete(id, NamedTransformationDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + ): NamedTransformation = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation + + /** @see delete */ + fun delete(params: NamedTransformationDeleteParams): NamedTransformation = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): NamedTransformation = + delete(id, NamedTransformationDeleteParams.none(), requestOptions) + + /** Retrieves the named transformation identified by `id`. */ + fun get(id: String): NamedTransformation = get(id, NamedTransformationGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + ): NamedTransformation = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NamedTransformation + + /** @see get */ + fun get(params: NamedTransformationGetParams): NamedTransformation = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): NamedTransformation = + get(id, NamedTransformationGetParams.none(), requestOptions) + + /** + * A view of [NamedTransformationService] 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 + ): NamedTransformationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/named-transformations`, but is otherwise the + * same as [NamedTransformationService.create]. + */ + @MustBeClosed + fun create(params: NamedTransformationCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/named-transformations/{id}`, but is otherwise + * the same as [NamedTransformationService.update]. + */ + @MustBeClosed + fun update(id: String): HttpResponseFor = + update(id, NamedTransformationUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: NamedTransformationUpdateParams = NamedTransformationUpdateParams.none(), + ): HttpResponseFor = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: NamedTransformationUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(id, NamedTransformationUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/named-transformations`, but is otherwise the + * same as [NamedTransformationService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = + list(NamedTransformationListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: NamedTransformationListParams = NamedTransformationListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(NamedTransformationListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/named-transformations/{id}`, but is otherwise + * the same as [NamedTransformationService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponseFor = + delete(id, NamedTransformationDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + ): HttpResponseFor = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see delete */ + @MustBeClosed + fun delete(params: NamedTransformationDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(id, NamedTransformationDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/named-transformations/{id}`, but is otherwise + * the same as [NamedTransformationService.get]. + */ + @MustBeClosed + fun get(id: String): HttpResponseFor = + get(id, NamedTransformationGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: NamedTransformationGetParams = NamedTransformationGetParams.none(), + ): HttpResponseFor = get(id, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: NamedTransformationGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + get(id, NamedTransformationGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt new file mode 100644 index 00000000..cbd0929d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.blocking + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +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.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.NamedTransformation +import io.imagekit.models.namedtransformations.NamedTransformationCreateParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationGetParams +import io.imagekit.models.namedtransformations.NamedTransformationListParams +import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class NamedTransformationServiceImpl +internal constructor(private val clientOptions: ClientOptions) : NamedTransformationService { + + private val withRawResponse: NamedTransformationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): NamedTransformationService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): NamedTransformationService = + NamedTransformationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions, + ): NamedTransformation = + // post /v1/named-transformations + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions, + ): NamedTransformation = + // patch /v1/named-transformations/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: NamedTransformationListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/named-transformations + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions, + ): NamedTransformation = + // delete /v1/named-transformations/{id} + withRawResponse().delete(params, requestOptions).parse() + + override fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions, + ): NamedTransformation = + // get /v1/named-transformations/{id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NamedTransformationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): NamedTransformationService.WithRawResponse = + NamedTransformationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: NamedTransformationCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: NamedTransformationUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: NamedTransformationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: NamedTransformationGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "named-transformations", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt new file mode 100644 index 00000000..b03b750b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import io.imagekit.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NamedTransformationTest { + + @Test + fun create() { + val namedTransformation = + NamedTransformation.builder() + .id("6bZ9x2ZUx") + .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) + .disabled(false) + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .build() + + assertThat(namedTransformation.id()).contains("6bZ9x2ZUx") + assertThat(namedTransformation.createdAt()) + .contains(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) + assertThat(namedTransformation.disabled()).contains(false) + assertThat(namedTransformation.name()).contains("small_thumbnail") + assertThat(namedTransformation.transformation()) + .contains("tr:w-150,h-150,fo-center,cm-resize") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val namedTransformation = + NamedTransformation.builder() + .id("6bZ9x2ZUx") + .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) + .disabled(false) + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .build() + + val roundtrippedNamedTransformation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(namedTransformation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNamedTransformation).isEqualTo(namedTransformation) + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt new file mode 100644 index 00000000..d1fee965 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NamedTransformationCreateParamsTest { + + @Test + fun create() { + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .disabled(false) + .build() + } + + @Test + fun body() { + val params = + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .disabled(false) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("small_thumbnail") + assertThat(body.transformation()).isEqualTo("tr:w-150,h-150,fo-center,cm-resize") + assertThat(body.disabled()).contains(false) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("small_thumbnail") + assertThat(body.transformation()).isEqualTo("tr:w-150,h-150,fo-center,cm-resize") + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt new file mode 100644 index 00000000..6d008c14 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NamedTransformationDeleteParamsTest { + + @Test + fun create() { + NamedTransformationDeleteParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = NamedTransformationDeleteParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt new file mode 100644 index 00000000..bb8fabec --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NamedTransformationGetParamsTest { + + @Test + fun create() { + NamedTransformationGetParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = NamedTransformationGetParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParamsTest.kt new file mode 100644 index 00000000..51322a9f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import org.junit.jupiter.api.Test + +internal class NamedTransformationListParamsTest { + + @Test + fun create() { + NamedTransformationListParams.builder().build() + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt new file mode 100644 index 00000000..a11c385c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NamedTransformationUpdateParamsTest { + + @Test + fun create() { + NamedTransformationUpdateParams.builder() + .id("id") + .disabled(true) + .name("small_thumbnail_v2") + .transformation("tr:w-200,h-200,fo-center,cm-resize") + .build() + } + + @Test + fun pathParams() { + val params = NamedTransformationUpdateParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + NamedTransformationUpdateParams.builder() + .id("id") + .disabled(true) + .name("small_thumbnail_v2") + .transformation("tr:w-200,h-200,fo-center,cm-resize") + .build() + + val body = params._body() + + assertThat(body.disabled()).contains(true) + assertThat(body.name()).contains("small_thumbnail_v2") + assertThat(body.transformation()).contains("tr:w-200,h-200,fo-center,cm-resize") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = NamedTransformationUpdateParams.builder().id("id").build() + + val body = params._body() + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt new file mode 100644 index 00000000..4da97115 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.async + +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.namedtransformations.NamedTransformationCreateParams +import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class NamedTransformationServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationServiceAsync = client.namedTransformations() + + val namedTransformationFuture = + namedTransformationServiceAsync.create( + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .disabled(false) + .build() + ) + + val namedTransformation = namedTransformationFuture.get() + namedTransformation.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationServiceAsync = client.namedTransformations() + + val namedTransformationFuture = + namedTransformationServiceAsync.update( + NamedTransformationUpdateParams.builder() + .id("id") + .disabled(true) + .name("small_thumbnail_v2") + .transformation("tr:w-200,h-200,fo-center,cm-resize") + .build() + ) + + val namedTransformation = namedTransformationFuture.get() + namedTransformation.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationServiceAsync = client.namedTransformations() + + val namedTransformationsFuture = namedTransformationServiceAsync.list() + + val namedTransformations = namedTransformationsFuture.get() + namedTransformations.forEach { it.validate() } + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationServiceAsync = client.namedTransformations() + + val namedTransformationFuture = namedTransformationServiceAsync.delete("id") + + val namedTransformation = namedTransformationFuture.get() + namedTransformation.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationServiceAsync = client.namedTransformations() + + val namedTransformationFuture = namedTransformationServiceAsync.get("id") + + val namedTransformation = namedTransformationFuture.get() + namedTransformation.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt new file mode 100644 index 00000000..2bcac4b0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.services.blocking + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.namedtransformations.NamedTransformationCreateParams +import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class NamedTransformationServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationService = client.namedTransformations() + + val namedTransformation = + namedTransformationService.create( + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .transformation("tr:w-150,h-150,fo-center,cm-resize") + .disabled(false) + .build() + ) + + namedTransformation.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationService = client.namedTransformations() + + val namedTransformation = + namedTransformationService.update( + NamedTransformationUpdateParams.builder() + .id("id") + .disabled(true) + .name("small_thumbnail_v2") + .transformation("tr:w-200,h-200,fo-center,cm-resize") + .build() + ) + + namedTransformation.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationService = client.namedTransformations() + + val namedTransformations = namedTransformationService.list() + + namedTransformations.forEach { it.validate() } + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationService = client.namedTransformations() + + val namedTransformation = namedTransformationService.delete("id") + + namedTransformation.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() + val namedTransformationService = client.namedTransformations() + + val namedTransformation = namedTransformationService.get("id") + + namedTransformation.validate() + } +} diff --git a/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt index 6976f2da..4ac5ce0d 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt @@ -64,6 +64,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.customMetadataFields()).isNotNull() assertThat(client.files()).isNotNull() assertThat(client.savedExtensions()).isNotNull() + assertThat(client.namedTransformations()).isNotNull() assertThat(client.assets()).isNotNull() assertThat(client.cache()).isNotNull() assertThat(client.folders()).isNotNull() From 4edbca74c30d0a36cb1517d49de10b5bb0fedf79 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 4 Aug 2026 10:23:15 +0000 Subject: [PATCH 02/10] Build SDK Stainless-Generated-From: 0aaf193010420d6b50addfb3ff3e720aa826e154 --- .../NamedTransformationDeleteParams.kt | 8 ++++---- .../services/async/NamedTransformationServiceAsync.kt | 8 ++++---- .../services/blocking/NamedTransformationService.kt | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt index b1f753ae..5c80eb78 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -17,10 +17,10 @@ import kotlin.jvm.optionals.getOrNull * **Note:** * - If another named transformation, or your account's upload * pre-transformation/post-transformation settings, reference this named transformation (via the - * `n-` token), the request fails with a `409` error and the response body includes a - * `references` array describing where it is used. Remove those references first, then retry the - * deletion. This is a best-effort check and cannot detect references baked into your own - * application code or previously generated URLs. + * `n-` token), the request fails with a `409` error whose `message` describes what it is + * referenced by. Remove those references first, then retry the deletion. This is a best-effort + * check and cannot detect references baked into your own application code or previously generated + * URLs. */ class NamedTransformationDeleteParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt index 565232c4..c619accf 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -108,10 +108,10 @@ interface NamedTransformationServiceAsync { * **Note:** * - If another named transformation, or your account's upload * pre-transformation/post-transformation settings, reference this named transformation (via - * the `n-` token), the request fails with a `409` error and the response body includes - * a `references` array describing where it is used. Remove those references first, then retry - * the deletion. This is a best-effort check and cannot detect references baked into your own - * application code or previously generated URLs. + * the `n-` token), the request fails with a `409` error whose `message` describes what + * it is referenced by. Remove those references first, then retry the deletion. This is a + * best-effort check and cannot detect references baked into your own application code or + * previously generated URLs. */ fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt index 36790a70..a1fa9ce6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -105,10 +105,10 @@ interface NamedTransformationService { * **Note:** * - If another named transformation, or your account's upload * pre-transformation/post-transformation settings, reference this named transformation (via - * the `n-` token), the request fails with a `409` error and the response body includes - * a `references` array describing where it is used. Remove those references first, then retry - * the deletion. This is a best-effort check and cannot detect references baked into your own - * application code or previously generated URLs. + * the `n-` token), the request fails with a `409` error whose `message` describes what + * it is referenced by. Remove those references first, then retry the deletion. This is a + * best-effort check and cannot detect references baked into your own application code or + * previously generated URLs. */ fun delete(id: String): NamedTransformation = delete(id, NamedTransformationDeleteParams.none()) From 5d0e729b9eca5a35232f44ef06bbfb309de92f67 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 7 Aug 2026 05:45:32 +0000 Subject: [PATCH 03/10] Build SDK Stainless-Generated-From: f7f8131d14d0028db7becff5496e8d721db1236f --- .../io/imagekit/models/NamedTransformation.kt | 57 ++++---- .../NamedTransformationCreateParams.kt | 121 +++++++++------- .../NamedTransformationDeleteParams.kt | 9 +- .../NamedTransformationUpdateParams.kt | 129 +++++++++++------- .../async/NamedTransformationServiceAsync.kt | 21 ++- .../blocking/NamedTransformationService.kt | 21 ++- .../models/NamedTransformationTest.kt | 6 +- .../NamedTransformationCreateParamsTest.kt | 16 +-- .../NamedTransformationUpdateParamsTest.kt | 12 +- .../NamedTransformationServiceAsyncTest.kt | 8 +- .../NamedTransformationServiceTest.kt | 8 +- 11 files changed, 239 insertions(+), 169 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt index fb08503c..0f2699cd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -26,7 +26,7 @@ class NamedTransformation private constructor( private val id: JsonField, private val createdAt: JsonField, - private val disabled: JsonField, + private val enabled: JsonField, private val name: JsonField, private val transformation: JsonField, private val additionalProperties: MutableMap, @@ -38,12 +38,12 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("disabled") @ExcludeMissing disabled: JsonField = JsonMissing.of(), + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing transformation: JsonField = JsonMissing.of(), - ) : this(id, createdAt, disabled, name, transformation, mutableMapOf()) + ) : this(id, createdAt, enabled, name, transformation, mutableMapOf()) /** * Unique identifier of the named transformation. This is generated by ImageKit when you create @@ -55,7 +55,7 @@ private constructor( fun id(): Optional = id.getOptional("id") /** - * Timestamp when the named transformation was created. + * Timestamp (ISO string) when the named transformation was created. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -63,12 +63,12 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this named transformation is currently disabled. + * Whether this named transformation is currently enabled. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun disabled(): Optional = disabled.getOptional("disabled") + fun enabled(): Optional = enabled.getOptional("enabled") /** * Name of the named transformation, used as `tr:n-` in image and video URLs. @@ -79,7 +79,8 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * The transformation string this name refers to. + * The transformation this name refers to. Always returned with the `tr:` prefix included, + * regardless of whether you supplied it when creating or updating the named transformation. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -103,11 +104,11 @@ private constructor( fun _createdAt(): JsonField = createdAt /** - * Returns the raw JSON value of [disabled]. + * Returns the raw JSON value of [enabled]. * - * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled /** * Returns the raw JSON value of [name]. @@ -148,7 +149,7 @@ private constructor( private var id: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var disabled: JsonField = JsonMissing.of() + private var enabled: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var transformation: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -157,7 +158,7 @@ private constructor( internal fun from(namedTransformation: NamedTransformation) = apply { id = namedTransformation.id createdAt = namedTransformation.createdAt - disabled = namedTransformation.disabled + enabled = namedTransformation.enabled name = namedTransformation.name transformation = namedTransformation.transformation additionalProperties = namedTransformation.additionalProperties.toMutableMap() @@ -177,7 +178,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - /** Timestamp when the named transformation was created. */ + /** Timestamp (ISO string) when the named transformation was created. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) /** @@ -189,17 +190,16 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this named transformation is currently disabled. */ - fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + /** Whether this named transformation is currently enabled. */ + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) /** - * Sets [Builder.disabled] to an arbitrary JSON value. + * Sets [Builder.enabled] to an arbitrary JSON value. * - * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } /** Name of the named transformation, used as `tr:n-` in image and video URLs. */ fun name(name: String) = name(JsonField.of(name)) @@ -212,7 +212,10 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** The transformation string this name refers to. */ + /** + * The transformation this name refers to. Always returned with the `tr:` prefix included, + * regardless of whether you supplied it when creating or updating the named transformation. + */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) /** @@ -254,7 +257,7 @@ private constructor( NamedTransformation( id, createdAt, - disabled, + enabled, name, transformation, additionalProperties.toMutableMap(), @@ -278,7 +281,7 @@ private constructor( id() createdAt() - disabled() + enabled() name() transformation() validated = true @@ -301,7 +304,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (disabled.asKnown().isPresent) 1 else 0) + + (if (enabled.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (transformation.asKnown().isPresent) 1 else 0) @@ -313,18 +316,18 @@ private constructor( return other is NamedTransformation && id == other.id && createdAt == other.createdAt && - disabled == other.disabled && + enabled == other.enabled && name == other.name && transformation == other.transformation && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, disabled, name, transformation, additionalProperties) + Objects.hash(id, createdAt, enabled, name, transformation, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "NamedTransformation{id=$id, createdAt=$createdAt, disabled=$disabled, name=$name, transformation=$transformation, additionalProperties=$additionalProperties}" + "NamedTransformation{id=$id, createdAt=$createdAt, enabled=$enabled, name=$name, transformation=$transformation, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt index 68b0df66..55a89083 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -28,6 +28,9 @@ import java.util.Optional * * Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + * + * **Note:** You can create up to 250 named transformations per account. Once this limit is reached, + * the request fails with a `400` error. */ class NamedTransformationCreateParams private constructor( @@ -39,7 +42,9 @@ private constructor( /** * Name of the named transformation. This is the alias used to refer to the transformation * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric - * characters, `_` and `-`, and must be unique for your account (case-insensitive). + * characters or `_` (hyphens are not allowed), and must be unique for your account. Name + * matching is case-sensitive, so `Small_Thumbnail` and `small_thumbnail` are treated as + * different names. * * @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). @@ -47,9 +52,11 @@ private constructor( fun name(): String = body.name() /** - * The transformation string this name refers to. It must start with `tr:` followed by one or - * more transformation parameters, for example `tr:w-150,h-150,fo-center,cm-resize`. Learn more - * about the [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation this name refers to, expressed as one or more comma-separated + * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not need to + * prefix this with `tr:` — it is added automatically. If you do include it, it must appear in + * lowercase at the start of the string, or the request is rejected. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -57,13 +64,13 @@ private constructor( fun transformation(): String = body.transformation() /** - * Whether this named transformation is disabled. Set to `true` to temporarily disable it + * Whether this named transformation is enabled. Set to `false` to temporarily disable it * without deleting it — requests using a disabled named transformation fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun disabled(): Optional = body.disabled() + fun enabled(): Optional = body.enabled() /** * Returns the raw JSON value of [name]. @@ -80,11 +87,11 @@ private constructor( fun _transformation(): JsonField = body._transformation() /** - * Returns the raw JSON value of [disabled]. + * Returns the raw JSON value of [enabled]. * - * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. */ - fun _disabled(): JsonField = body._disabled() + fun _enabled(): JsonField = body._enabled() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -134,14 +141,16 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [name] * - [transformation] - * - [disabled] + * - [enabled] */ fun body(body: Body) = apply { this.body = body.toBuilder() } /** * Name of the named transformation. This is the alias used to refer to the transformation * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric - * characters, `_` and `-`, and must be unique for your account (case-insensitive). + * characters or `_` (hyphens are not allowed), and must be unique for your account. Name + * matching is case-sensitive, so `Small_Thumbnail` and `small_thumbnail` are treated as + * different names. */ fun name(name: String) = apply { body.name(name) } @@ -154,9 +163,11 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** - * The transformation string this name refers to. It must start with `tr:` followed by one - * or more transformation parameters, for example `tr:w-150,h-150,fo-center,cm-resize`. - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation this name refers to, expressed as one or more comma-separated + * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not need + * to prefix this with `tr:` — it is added automatically. If you do include it, it must + * appear in lowercase at the start of the string, or the request is rejected. Learn more + * about the [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -172,20 +183,19 @@ private constructor( } /** - * Whether this named transformation is disabled. Set to `true` to temporarily disable it + * Whether this named transformation is enabled. Set to `false` to temporarily disable it * without deleting it — requests using a disabled named transformation fail at delivery * time. */ - fun disabled(disabled: Boolean) = apply { body.disabled(disabled) } + fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } /** - * Sets [Builder.disabled] to an arbitrary JSON value. + * Sets [Builder.enabled] to an arbitrary JSON value. * - * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun disabled(disabled: JsonField) = apply { body.disabled(disabled) } + fun enabled(enabled: JsonField) = apply { body.enabled(enabled) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -336,7 +346,7 @@ private constructor( private constructor( private val name: JsonField, private val transformation: JsonField, - private val disabled: JsonField, + private val enabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -346,15 +356,15 @@ private constructor( @JsonProperty("transformation") @ExcludeMissing transformation: JsonField = JsonMissing.of(), - @JsonProperty("disabled") - @ExcludeMissing - disabled: JsonField = JsonMissing.of(), - ) : this(name, transformation, disabled, mutableMapOf()) + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + ) : this(name, transformation, enabled, mutableMapOf()) /** * Name of the named transformation. This is the alias used to refer to the transformation * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric - * characters, `_` and `-`, and must be unique for your account (case-insensitive). + * characters or `_` (hyphens are not allowed), and must be unique for your account. Name + * matching is case-sensitive, so `Small_Thumbnail` and `small_thumbnail` are treated as + * different names. * * @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). @@ -362,9 +372,11 @@ private constructor( fun name(): String = name.getRequired("name") /** - * The transformation string this name refers to. It must start with `tr:` followed by one - * or more transformation parameters, for example `tr:w-150,h-150,fo-center,cm-resize`. - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation this name refers to, expressed as one or more comma-separated + * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not need + * to prefix this with `tr:` — it is added automatically. If you do include it, it must + * appear in lowercase at the start of the string, or the request is rejected. Learn more + * about the [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -372,14 +384,14 @@ private constructor( fun transformation(): String = transformation.getRequired("transformation") /** - * Whether this named transformation is disabled. Set to `true` to temporarily disable it + * Whether this named transformation is enabled. Set to `false` to temporarily disable it * without deleting it — requests using a disabled named transformation fail at delivery * time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun disabled(): Optional = disabled.getOptional("disabled") + fun enabled(): Optional = enabled.getOptional("enabled") /** * Returns the raw JSON value of [name]. @@ -399,11 +411,11 @@ private constructor( fun _transformation(): JsonField = transformation /** - * Returns the raw JSON value of [disabled]. + * Returns the raw JSON value of [enabled]. * - * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -436,22 +448,23 @@ private constructor( private var name: JsonField? = null private var transformation: JsonField? = null - private var disabled: JsonField = JsonMissing.of() + private var enabled: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { name = body.name transformation = body.transformation - disabled = body.disabled + enabled = body.enabled additionalProperties = body.additionalProperties.toMutableMap() } /** * Name of the named transformation. This is the alias used to refer to the * transformation string in image and video URLs, for example `tr:n-`. Can only - * contain alphanumeric characters, `_` and `-`, and must be unique for your account - * (case-insensitive). + * contain alphanumeric characters or `_` (hyphens are not allowed), and must be unique + * for your account. Name matching is case-sensitive, so `Small_Thumbnail` and + * `small_thumbnail` are treated as different names. */ fun name(name: String) = name(JsonField.of(name)) @@ -465,9 +478,11 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * The transformation string this name refers to. It must start with `tr:` followed by - * one or more transformation parameters, for example - * `tr:w-150,h-150,fo-center,cm-resize`. Learn more about the + * The transformation this name refers to, expressed as one or more comma-separated + * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not + * need to prefix this with `tr:` — it is added automatically. If you do include it, it + * must appear in lowercase at the start of the string, or the request is rejected. + * Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = @@ -485,20 +500,20 @@ private constructor( } /** - * Whether this named transformation is disabled. Set to `true` to temporarily disable + * Whether this named transformation is enabled. Set to `false` to temporarily disable * it without deleting it — requests using a disabled named transformation fail at * delivery time. */ - fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) /** - * Sets [Builder.disabled] to an arbitrary JSON value. + * Sets [Builder.enabled] to an arbitrary JSON value. * - * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -536,7 +551,7 @@ private constructor( Body( checkRequired("name", name), checkRequired("transformation", transformation), - disabled, + enabled, additionalProperties.toMutableMap(), ) } @@ -559,7 +574,7 @@ private constructor( name() transformation() - disabled() + enabled() validated = true } @@ -581,7 +596,7 @@ private constructor( internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + (if (transformation.asKnown().isPresent) 1 else 0) + - (if (disabled.asKnown().isPresent) 1 else 0) + (if (enabled.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -591,18 +606,18 @@ private constructor( return other is Body && name == other.name && transformation == other.transformation && - disabled == other.disabled && + enabled == other.enabled && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, transformation, disabled, additionalProperties) + Objects.hash(name, transformation, enabled, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, transformation=$transformation, disabled=$disabled, additionalProperties=$additionalProperties}" + "Body{name=$name, transformation=$transformation, enabled=$enabled, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt index 5c80eb78..e76e52ce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -15,12 +15,13 @@ import kotlin.jvm.optionals.getOrNull * Permanently deletes the named transformation identified by `id` and returns the deleted object. * * **Note:** - * - If another named transformation, or your account's upload + * - If another *enabled* named transformation, or your account's upload * pre-transformation/post-transformation settings, reference this named transformation (via the * `n-` token), the request fails with a `409` error whose `message` describes what it is - * referenced by. Remove those references first, then retry the deletion. This is a best-effort - * check and cannot detect references baked into your own application code or previously generated - * URLs. + * referenced by. A reference from a named transformation that is itself disabled does not block + * this request. Remove or disable those references first, then retry the deletion. This is a + * best-effort check and cannot detect references baked into your own application code or + * previously generated URLs. */ class NamedTransformationDeleteParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt index c439c4f3..e8b9be0c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -22,6 +22,15 @@ import kotlin.jvm.optionals.getOrNull /** * Updates the named transformation identified by `id` and returns the updated object. Only the * fields present in the request body are updated; omitted fields are left unchanged. + * + * **Note:** + * - If you rename this named transformation, or set `enabled` to `false`, and another *enabled* + * named transformation, or your account's upload pre-transformation/post-transformation settings, + * reference it (via the `n-` token), the request fails with a `409` error whose `message` + * describes what it is referenced by. A reference from a named transformation that is itself + * disabled does not block this request. Remove or disable those references first, then retry. + * This is a best-effort check and cannot detect references baked into your own application code + * or previously generated URLs. */ class NamedTransformationUpdateParams private constructor( @@ -34,16 +43,18 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** - * Whether this named transformation is disabled. + * Whether this named transformation is enabled. If omitted, the existing value is left + * unchanged. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun disabled(): Optional = body.disabled() + fun enabled(): Optional = body.enabled() /** - * Updated name of the named transformation. Can only contain alphanumeric characters, `_` and - * `-`, and must be unique for your account (case-insensitive). + * Updated name of the named transformation. Can only contain alphanumeric characters and `_`, + * and must be unique for your account. Name matching is case-sensitive, so `Small_Thumbnail` + * and `small_thumbnail` are treated as different names. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -51,8 +62,9 @@ private constructor( fun name(): Optional = body.name() /** - * Updated transformation string. It must start with `tr:` followed by one or more - * transformation parameters. + * Updated transformation, expressed as one or more comma-separated transformation parameters. + * You do not need to prefix this with `tr:` — it is added automatically. If you do include it, + * it must appear in lowercase at the start of the string, or the request is rejected. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -60,11 +72,11 @@ private constructor( fun transformation(): Optional = body.transformation() /** - * Returns the raw JSON value of [disabled]. + * Returns the raw JSON value of [enabled]. * - * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. */ - fun _disabled(): JsonField = body._disabled() + fun _enabled(): JsonField = body._enabled() /** * Returns the raw JSON value of [name]. @@ -129,27 +141,30 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: - * - [disabled] + * - [enabled] * - [name] * - [transformation] */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** Whether this named transformation is disabled. */ - fun disabled(disabled: Boolean) = apply { body.disabled(disabled) } + /** + * Whether this named transformation is enabled. If omitted, the existing value is left + * unchanged. + */ + fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } /** - * Sets [Builder.disabled] to an arbitrary JSON value. + * Sets [Builder.enabled] to an arbitrary JSON value. * - * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun disabled(disabled: JsonField) = apply { body.disabled(disabled) } + fun enabled(enabled: JsonField) = apply { body.enabled(enabled) } /** - * Updated name of the named transformation. Can only contain alphanumeric characters, `_` - * and `-`, and must be unique for your account (case-insensitive). + * Updated name of the named transformation. Can only contain alphanumeric characters and + * `_`, and must be unique for your account. Name matching is case-sensitive, so + * `Small_Thumbnail` and `small_thumbnail` are treated as different names. */ fun name(name: String) = apply { body.name(name) } @@ -162,8 +177,10 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** - * Updated transformation string. It must start with `tr:` followed by one or more - * transformation parameters. + * Updated transformation, expressed as one or more comma-separated transformation + * parameters. You do not need to prefix this with `tr:` — it is added automatically. If you + * do include it, it must appear in lowercase at the start of the string, or the request is + * rejected. */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -324,7 +341,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val disabled: JsonField, + private val enabled: JsonField, private val name: JsonField, private val transformation: JsonField, private val additionalProperties: MutableMap, @@ -332,26 +349,26 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("disabled") - @ExcludeMissing - disabled: JsonField = JsonMissing.of(), + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing transformation: JsonField = JsonMissing.of(), - ) : this(disabled, name, transformation, mutableMapOf()) + ) : this(enabled, name, transformation, mutableMapOf()) /** - * Whether this named transformation is disabled. + * Whether this named transformation is enabled. If omitted, the existing value is left + * unchanged. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun disabled(): Optional = disabled.getOptional("disabled") + fun enabled(): Optional = enabled.getOptional("enabled") /** - * Updated name of the named transformation. Can only contain alphanumeric characters, `_` - * and `-`, and must be unique for your account (case-insensitive). + * Updated name of the named transformation. Can only contain alphanumeric characters and + * `_`, and must be unique for your account. Name matching is case-sensitive, so + * `Small_Thumbnail` and `small_thumbnail` are treated as different names. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -359,8 +376,10 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * Updated transformation string. It must start with `tr:` followed by one or more - * transformation parameters. + * Updated transformation, expressed as one or more comma-separated transformation + * parameters. You do not need to prefix this with `tr:` — it is added automatically. If you + * do include it, it must appear in lowercase at the start of the string, or the request is + * rejected. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -368,11 +387,11 @@ private constructor( fun transformation(): Optional = transformation.getOptional("transformation") /** - * Returns the raw JSON value of [disabled]. + * Returns the raw JSON value of [enabled]. * - * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled /** * Returns the raw JSON value of [name]. @@ -412,34 +431,38 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var disabled: JsonField = JsonMissing.of() + private var enabled: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var transformation: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { - disabled = body.disabled + enabled = body.enabled name = body.name transformation = body.transformation additionalProperties = body.additionalProperties.toMutableMap() } - /** Whether this named transformation is disabled. */ - fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) + /** + * Whether this named transformation is enabled. If omitted, the existing value is left + * unchanged. + */ + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) /** - * Sets [Builder.disabled] to an arbitrary JSON value. + * Sets [Builder.enabled] to an arbitrary JSON value. * - * You should usually call [Builder.disabled] with a well-typed [Boolean] value instead. + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } /** - * Updated name of the named transformation. Can only contain alphanumeric characters, - * `_` and `-`, and must be unique for your account (case-insensitive). + * Updated name of the named transformation. Can only contain alphanumeric characters + * and `_`, and must be unique for your account. Name matching is case-sensitive, so + * `Small_Thumbnail` and `small_thumbnail` are treated as different names. */ fun name(name: String) = name(JsonField.of(name)) @@ -453,8 +476,10 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * Updated transformation string. It must start with `tr:` followed by one or more - * transformation parameters. + * Updated transformation, expressed as one or more comma-separated transformation + * parameters. You do not need to prefix this with `tr:` — it is added automatically. If + * you do include it, it must appear in lowercase at the start of the string, or the + * request is rejected. */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) @@ -495,7 +520,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(disabled, name, transformation, additionalProperties.toMutableMap()) + Body(enabled, name, transformation, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -514,7 +539,7 @@ private constructor( return@apply } - disabled() + enabled() name() transformation() validated = true @@ -536,7 +561,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (disabled.asKnown().isPresent) 1 else 0) + + (if (enabled.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (transformation.asKnown().isPresent) 1 else 0) @@ -546,20 +571,20 @@ private constructor( } return other is Body && - disabled == other.disabled && + enabled == other.enabled && name == other.name && transformation == other.transformation && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(disabled, name, transformation, additionalProperties) + Objects.hash(enabled, name, transformation, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{disabled=$disabled, name=$name, transformation=$transformation, additionalProperties=$additionalProperties}" + "Body{enabled=$enabled, name=$name, transformation=$transformation, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt index c619accf..c0414927 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -37,6 +37,9 @@ interface NamedTransformationServiceAsync { * * Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + * + * **Note:** You can create up to 250 named transformations per account. Once this limit is + * reached, the request fails with a `400` error. */ fun create(params: NamedTransformationCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -50,6 +53,15 @@ interface NamedTransformationServiceAsync { /** * Updates the named transformation identified by `id` and returns the updated object. Only the * fields present in the request body are updated; omitted fields are left unchanged. + * + * **Note:** + * - If you rename this named transformation, or set `enabled` to `false`, and another *enabled* + * named transformation, or your account's upload pre-transformation/post-transformation + * settings, reference it (via the `n-` token), the request fails with a `409` error + * whose `message` describes what it is referenced by. A reference from a named transformation + * that is itself disabled does not block this request. Remove or disable those references + * first, then retry. This is a best-effort check and cannot detect references baked into your + * own application code or previously generated URLs. */ fun update(id: String): CompletableFuture = update(id, NamedTransformationUpdateParams.none()) @@ -106,12 +118,13 @@ interface NamedTransformationServiceAsync { * object. * * **Note:** - * - If another named transformation, or your account's upload + * - If another *enabled* named transformation, or your account's upload * pre-transformation/post-transformation settings, reference this named transformation (via * the `n-` token), the request fails with a `409` error whose `message` describes what - * it is referenced by. Remove those references first, then retry the deletion. This is a - * best-effort check and cannot detect references baked into your own application code or - * previously generated URLs. + * it is referenced by. A reference from a named transformation that is itself disabled does + * not block this request. Remove or disable those references first, then retry the deletion. + * This is a best-effort check and cannot detect references baked into your own application + * code or previously generated URLs. */ fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt index a1fa9ce6..94089280 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -37,6 +37,9 @@ interface NamedTransformationService { * * Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). + * + * **Note:** You can create up to 250 named transformations per account. Once this limit is + * reached, the request fails with a `400` error. */ fun create(params: NamedTransformationCreateParams): NamedTransformation = create(params, RequestOptions.none()) @@ -50,6 +53,15 @@ interface NamedTransformationService { /** * Updates the named transformation identified by `id` and returns the updated object. Only the * fields present in the request body are updated; omitted fields are left unchanged. + * + * **Note:** + * - If you rename this named transformation, or set `enabled` to `false`, and another *enabled* + * named transformation, or your account's upload pre-transformation/post-transformation + * settings, reference it (via the `n-` token), the request fails with a `409` error + * whose `message` describes what it is referenced by. A reference from a named transformation + * that is itself disabled does not block this request. Remove or disable those references + * first, then retry. This is a best-effort check and cannot detect references baked into your + * own application code or previously generated URLs. */ fun update(id: String): NamedTransformation = update(id, NamedTransformationUpdateParams.none()) @@ -103,12 +115,13 @@ interface NamedTransformationService { * object. * * **Note:** - * - If another named transformation, or your account's upload + * - If another *enabled* named transformation, or your account's upload * pre-transformation/post-transformation settings, reference this named transformation (via * the `n-` token), the request fails with a `409` error whose `message` describes what - * it is referenced by. Remove those references first, then retry the deletion. This is a - * best-effort check and cannot detect references baked into your own application code or - * previously generated URLs. + * it is referenced by. A reference from a named transformation that is itself disabled does + * not block this request. Remove or disable those references first, then retry the deletion. + * This is a best-effort check and cannot detect references baked into your own application + * code or previously generated URLs. */ fun delete(id: String): NamedTransformation = delete(id, NamedTransformationDeleteParams.none()) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt index b03b750b..a8507f8a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt @@ -16,7 +16,7 @@ internal class NamedTransformationTest { NamedTransformation.builder() .id("6bZ9x2ZUx") .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) - .disabled(false) + .enabled(true) .name("small_thumbnail") .transformation("tr:w-150,h-150,fo-center,cm-resize") .build() @@ -24,7 +24,7 @@ internal class NamedTransformationTest { assertThat(namedTransformation.id()).contains("6bZ9x2ZUx") assertThat(namedTransformation.createdAt()) .contains(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) - assertThat(namedTransformation.disabled()).contains(false) + assertThat(namedTransformation.enabled()).contains(true) assertThat(namedTransformation.name()).contains("small_thumbnail") assertThat(namedTransformation.transformation()) .contains("tr:w-150,h-150,fo-center,cm-resize") @@ -37,7 +37,7 @@ internal class NamedTransformationTest { NamedTransformation.builder() .id("6bZ9x2ZUx") .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) - .disabled(false) + .enabled(true) .name("small_thumbnail") .transformation("tr:w-150,h-150,fo-center,cm-resize") .build() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt index d1fee965..1adeab2d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt @@ -11,8 +11,8 @@ internal class NamedTransformationCreateParamsTest { fun create() { NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") - .disabled(false) + .transformation("w-150,h-150,fo-center,cm-resize") + .enabled(true) .build() } @@ -21,15 +21,15 @@ internal class NamedTransformationCreateParamsTest { val params = NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") - .disabled(false) + .transformation("w-150,h-150,fo-center,cm-resize") + .enabled(true) .build() val body = params._body() assertThat(body.name()).isEqualTo("small_thumbnail") - assertThat(body.transformation()).isEqualTo("tr:w-150,h-150,fo-center,cm-resize") - assertThat(body.disabled()).contains(false) + assertThat(body.transformation()).isEqualTo("w-150,h-150,fo-center,cm-resize") + assertThat(body.enabled()).contains(true) } @Test @@ -37,12 +37,12 @@ internal class NamedTransformationCreateParamsTest { val params = NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-resize") .build() val body = params._body() assertThat(body.name()).isEqualTo("small_thumbnail") - assertThat(body.transformation()).isEqualTo("tr:w-150,h-150,fo-center,cm-resize") + assertThat(body.transformation()).isEqualTo("w-150,h-150,fo-center,cm-resize") } } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt index a11c385c..103478ed 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt @@ -11,9 +11,9 @@ internal class NamedTransformationUpdateParamsTest { fun create() { NamedTransformationUpdateParams.builder() .id("id") - .disabled(true) + .enabled(true) .name("small_thumbnail_v2") - .transformation("tr:w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-resize") .build() } @@ -31,16 +31,16 @@ internal class NamedTransformationUpdateParamsTest { val params = NamedTransformationUpdateParams.builder() .id("id") - .disabled(true) + .enabled(true) .name("small_thumbnail_v2") - .transformation("tr:w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-resize") .build() val body = params._body() - assertThat(body.disabled()).contains(true) + assertThat(body.enabled()).contains(true) assertThat(body.name()).contains("small_thumbnail_v2") - assertThat(body.transformation()).contains("tr:w-200,h-200,fo-center,cm-resize") + assertThat(body.transformation()).contains("w-200,h-200,fo-center,cm-resize") } @Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt index 4da97115..9c63105b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -24,8 +24,8 @@ internal class NamedTransformationServiceAsyncTest { namedTransformationServiceAsync.create( NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") - .disabled(false) + .transformation("w-150,h-150,fo-center,cm-resize") + .enabled(true) .build() ) @@ -47,9 +47,9 @@ internal class NamedTransformationServiceAsyncTest { namedTransformationServiceAsync.update( NamedTransformationUpdateParams.builder() .id("id") - .disabled(true) + .enabled(true) .name("small_thumbnail_v2") - .transformation("tr:w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-resize") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt index 2bcac4b0..17fede86 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -24,8 +24,8 @@ internal class NamedTransformationServiceTest { namedTransformationService.create( NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") - .disabled(false) + .transformation("w-150,h-150,fo-center,cm-resize") + .enabled(true) .build() ) @@ -46,9 +46,9 @@ internal class NamedTransformationServiceTest { namedTransformationService.update( NamedTransformationUpdateParams.builder() .id("id") - .disabled(true) + .enabled(true) .name("small_thumbnail_v2") - .transformation("tr:w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-resize") .build() ) From cd94707ccdee0a2f8ec3ae5b769e6f4d05041398 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 7 Aug 2026 07:06:29 +0000 Subject: [PATCH 04/10] Build SDK Stainless-Generated-From: 2ed297724b6a27e25729006622f7fe956c7b46e8 --- .../io/imagekit/models/NamedTransformation.kt | 28 +++--- .../NamedTransformationCreateParams.kt | 96 ++++++++----------- .../NamedTransformationDeleteParams.kt | 13 +-- .../NamedTransformationUpdateParams.kt | 80 +++++++--------- .../async/NamedTransformationServiceAsync.kt | 39 +++----- .../blocking/NamedTransformationService.kt | 39 +++----- .../NamedTransformationUpdateParamsTest.kt | 6 +- .../NamedTransformationServiceAsyncTest.kt | 2 +- .../NamedTransformationServiceTest.kt | 2 +- 9 files changed, 127 insertions(+), 178 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt index 0f2699cd..4619fb20 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -17,8 +17,8 @@ import java.util.Objects import java.util.Optional /** - * A named transformation is an alias for an actual transformation string, allowing you to apply and - * later update complex transformations without changing your image or video URLs. Learn more about + * A named transformation is an alias for a transformation string, letting you apply and later + * update complex transformations without changing your image or video URLs. Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). */ class NamedTransformation @@ -46,8 +46,7 @@ private constructor( ) : this(id, createdAt, enabled, name, transformation, mutableMapOf()) /** - * Unique identifier of the named transformation. This is generated by ImageKit when you create - * a new named transformation. + * Unique identifier generated by ImageKit when the named transformation was created. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -55,7 +54,7 @@ private constructor( fun id(): Optional = id.getOptional("id") /** - * Timestamp (ISO string) when the named transformation was created. + * ISO 8601 timestamp of when the named transformation was created. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -63,7 +62,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this named transformation is currently enabled. + * Whether the named transformation is currently enabled. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -79,8 +78,8 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * The transformation this name refers to. Always returned with the `tr:` prefix included, - * regardless of whether you supplied it when creating or updating the named transformation. + * Transformation string this name refers to. Always includes the `tr:` prefix, even if you + * omitted it in the request. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -164,10 +163,7 @@ private constructor( additionalProperties = namedTransformation.additionalProperties.toMutableMap() } - /** - * Unique identifier of the named transformation. This is generated by ImageKit when you - * create a new named transformation. - */ + /** Unique identifier generated by ImageKit when the named transformation was created. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -178,7 +174,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - /** Timestamp (ISO string) when the named transformation was created. */ + /** ISO 8601 timestamp of when the named transformation was created. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) /** @@ -190,7 +186,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this named transformation is currently enabled. */ + /** Whether the named transformation is currently enabled. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) /** @@ -213,8 +209,8 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * The transformation this name refers to. Always returned with the `tr:` prefix included, - * regardless of whether you supplied it when creating or updating the named transformation. + * Transformation string this name refers to. Always includes the `tr:` prefix, even if you + * omitted it in the request. */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt index 55a89083..28abb76e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -22,15 +22,12 @@ import java.util.Optional /** * Creates a new named transformation and returns the created object. * - * Named transformations let you assign a short, reusable name to a complex transformation string, - * so it can be applied in image and video URLs as `tr:n-` and later updated without changing - * any existing URLs. - * - * Learn more about + * A named transformation is a short, reusable name for a transformation string. Use it in image and + * video URLs as `tr:n-`, and update the underlying transformation later without changing + * existing URLs. Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). * - * **Note:** You can create up to 250 named transformations per account. Once this limit is reached, - * the request fails with a `400` error. + * You can create up to 250 named transformations per account. */ class NamedTransformationCreateParams private constructor( @@ -40,11 +37,9 @@ private constructor( ) : Params { /** - * Name of the named transformation. This is the alias used to refer to the transformation - * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric - * characters or `_` (hyphens are not allowed), and must be unique for your account. Name - * matching is case-sensitive, so `Small_Thumbnail` and `small_thumbnail` are treated as - * different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name matching is + * case-sensitive. * * @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). @@ -52,11 +47,9 @@ private constructor( fun name(): String = body.name() /** - * The transformation this name refers to, expressed as one or more comma-separated - * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not need to - * prefix this with `tr:` — it is added automatically. If you do include it, it must appear in - * lowercase at the start of the string, or the request is rejected. Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. + * The `tr:` prefix is optional — it's added automatically if missing, and validated if present. + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -64,8 +57,8 @@ private constructor( fun transformation(): String = body.transformation() /** - * Whether this named transformation is enabled. Set to `false` to temporarily disable it - * without deleting it — requests using a disabled named transformation fail at delivery time. + * Whether the named transformation is enabled. Set to `false` to disable it without deleting + * it; requests using a disabled named transformation fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -146,11 +139,9 @@ private constructor( fun body(body: Body) = apply { this.body = body.toBuilder() } /** - * Name of the named transformation. This is the alias used to refer to the transformation - * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric - * characters or `_` (hyphens are not allowed), and must be unique for your account. Name - * matching is case-sensitive, so `Small_Thumbnail` and `small_thumbnail` are treated as - * different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. */ fun name(name: String) = apply { body.name(name) } @@ -163,11 +154,10 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** - * The transformation this name refers to, expressed as one or more comma-separated - * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not need - * to prefix this with `tr:` — it is added automatically. If you do include it, it must - * appear in lowercase at the start of the string, or the request is rejected. Learn more - * about the [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added + * automatically if missing, and validated if present. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -183,9 +173,8 @@ private constructor( } /** - * Whether this named transformation is enabled. Set to `false` to temporarily disable it - * without deleting it — requests using a disabled named transformation fail at delivery - * time. + * Whether the named transformation is enabled. Set to `false` to disable it without + * deleting it; requests using a disabled named transformation fail at delivery time. */ fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } @@ -360,11 +349,9 @@ private constructor( ) : this(name, transformation, enabled, mutableMapOf()) /** - * Name of the named transformation. This is the alias used to refer to the transformation - * string in image and video URLs, for example `tr:n-`. Can only contain alphanumeric - * characters or `_` (hyphens are not allowed), and must be unique for your account. Name - * matching is case-sensitive, so `Small_Thumbnail` and `small_thumbnail` are treated as - * different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. * * @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). @@ -372,11 +359,10 @@ private constructor( fun name(): String = name.getRequired("name") /** - * The transformation this name refers to, expressed as one or more comma-separated - * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not need - * to prefix this with `tr:` — it is added automatically. If you do include it, it must - * appear in lowercase at the start of the string, or the request is rejected. Learn more - * about the [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added + * automatically if missing, and validated if present. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -384,9 +370,8 @@ private constructor( fun transformation(): String = transformation.getRequired("transformation") /** - * Whether this named transformation is enabled. Set to `false` to temporarily disable it - * without deleting it — requests using a disabled named transformation fail at delivery - * time. + * Whether the named transformation is enabled. Set to `false` to disable it without + * deleting it; requests using a disabled named transformation fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -460,11 +445,9 @@ private constructor( } /** - * Name of the named transformation. This is the alias used to refer to the - * transformation string in image and video URLs, for example `tr:n-`. Can only - * contain alphanumeric characters or `_` (hyphens are not allowed), and must be unique - * for your account. Name matching is case-sensitive, so `Small_Thumbnail` and - * `small_thumbnail` are treated as different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. */ fun name(name: String) = name(JsonField.of(name)) @@ -478,11 +461,9 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * The transformation this name refers to, expressed as one or more comma-separated - * transformation parameters, for example `w-150,h-150,fo-center,cm-resize`. You do not - * need to prefix this with `tr:` — it is added automatically. If you do include it, it - * must appear in lowercase at the start of the string, or the request is rejected. - * Learn more about the + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added + * automatically if missing, and validated if present. Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = @@ -500,9 +481,8 @@ private constructor( } /** - * Whether this named transformation is enabled. Set to `false` to temporarily disable - * it without deleting it — requests using a disabled named transformation fail at - * delivery time. + * Whether the named transformation is enabled. Set to `false` to disable it without + * deleting it; requests using a disabled named transformation fail at delivery time. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt index e76e52ce..574308e4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -14,14 +14,11 @@ import kotlin.jvm.optionals.getOrNull /** * Permanently deletes the named transformation identified by `id` and returns the deleted object. * - * **Note:** - * - If another *enabled* named transformation, or your account's upload - * pre-transformation/post-transformation settings, reference this named transformation (via the - * `n-` token), the request fails with a `409` error whose `message` describes what it is - * referenced by. A reference from a named transformation that is itself disabled does not block - * this request. Remove or disable those references first, then retry the deletion. This is a - * best-effort check and cannot detect references baked into your own application code or - * previously generated URLs. + * Deletion fails with a `409` error if the named transformation is still referenced (via the + * `n-` token) by another enabled named transformation, or by an upload + * pre-transformation/post-transformation setting. References from disabled named transformations + * don't count. This check is best-effort and can't detect references in your own application code + * or in previously generated URLs. */ class NamedTransformationDeleteParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt index e8b9be0c..5089720c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -21,16 +21,13 @@ import kotlin.jvm.optionals.getOrNull /** * Updates the named transformation identified by `id` and returns the updated object. Only the - * fields present in the request body are updated; omitted fields are left unchanged. + * fields present in the request body are updated; other fields stay unchanged. * - * **Note:** - * - If you rename this named transformation, or set `enabled` to `false`, and another *enabled* - * named transformation, or your account's upload pre-transformation/post-transformation settings, - * reference it (via the `n-` token), the request fails with a `409` error whose `message` - * describes what it is referenced by. A reference from a named transformation that is itself - * disabled does not block this request. Remove or disable those references first, then retry. - * This is a best-effort check and cannot detect references baked into your own application code - * or previously generated URLs. + * Renaming or disabling a named transformation fails with a `409` error if it is still referenced + * (via the `n-` token) by another enabled named transformation, or by an upload + * pre-transformation/post-transformation setting. References from disabled named transformations + * don't count. This check is best-effort and can't detect references in your own application code + * or in previously generated URLs. */ class NamedTransformationUpdateParams private constructor( @@ -43,8 +40,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** - * Whether this named transformation is enabled. If omitted, the existing value is left - * unchanged. + * Whether the named transformation is enabled. Omit to leave the current value unchanged. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -52,9 +48,9 @@ private constructor( fun enabled(): Optional = body.enabled() /** - * Updated name of the named transformation. Can only contain alphanumeric characters and `_`, - * and must be unique for your account. Name matching is case-sensitive, so `Small_Thumbnail` - * and `small_thumbnail` are treated as different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name matching is + * case-sensitive. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -62,9 +58,9 @@ private constructor( fun name(): Optional = body.name() /** - * Updated transformation, expressed as one or more comma-separated transformation parameters. - * You do not need to prefix this with `tr:` — it is added automatically. If you do include it, - * it must appear in lowercase at the start of the string, or the request is rejected. + * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. + * The `tr:` prefix is optional — it's added automatically if missing, and validated if present. + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -148,8 +144,7 @@ private constructor( fun body(body: Body) = apply { this.body = body.toBuilder() } /** - * Whether this named transformation is enabled. If omitted, the existing value is left - * unchanged. + * Whether the named transformation is enabled. Omit to leave the current value unchanged. */ fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } @@ -162,9 +157,9 @@ private constructor( fun enabled(enabled: JsonField) = apply { body.enabled(enabled) } /** - * Updated name of the named transformation. Can only contain alphanumeric characters and - * `_`, and must be unique for your account. Name matching is case-sensitive, so - * `Small_Thumbnail` and `small_thumbnail` are treated as different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. */ fun name(name: String) = apply { body.name(name) } @@ -177,10 +172,10 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** - * Updated transformation, expressed as one or more comma-separated transformation - * parameters. You do not need to prefix this with `tr:` — it is added automatically. If you - * do include it, it must appear in lowercase at the start of the string, or the request is - * rejected. + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added + * automatically if missing, and validated if present. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -357,8 +352,7 @@ private constructor( ) : this(enabled, name, transformation, mutableMapOf()) /** - * Whether this named transformation is enabled. If omitted, the existing value is left - * unchanged. + * Whether the named transformation is enabled. Omit to leave the current value unchanged. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -366,9 +360,9 @@ private constructor( fun enabled(): Optional = enabled.getOptional("enabled") /** - * Updated name of the named transformation. Can only contain alphanumeric characters and - * `_`, and must be unique for your account. Name matching is case-sensitive, so - * `Small_Thumbnail` and `small_thumbnail` are treated as different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -376,10 +370,10 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * Updated transformation, expressed as one or more comma-separated transformation - * parameters. You do not need to prefix this with `tr:` — it is added automatically. If you - * do include it, it must appear in lowercase at the start of the string, or the request is - * rejected. + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added + * automatically if missing, and validated if present. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -445,7 +439,7 @@ private constructor( } /** - * Whether this named transformation is enabled. If omitted, the existing value is left + * Whether the named transformation is enabled. Omit to leave the current value * unchanged. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) @@ -460,9 +454,9 @@ private constructor( fun enabled(enabled: JsonField) = apply { this.enabled = enabled } /** - * Updated name of the named transformation. Can only contain alphanumeric characters - * and `_`, and must be unique for your account. Name matching is case-sensitive, so - * `Small_Thumbnail` and `small_thumbnail` are treated as different names. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. */ fun name(name: String) = name(JsonField.of(name)) @@ -476,10 +470,10 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * Updated transformation, expressed as one or more comma-separated transformation - * parameters. You do not need to prefix this with `tr:` — it is added automatically. If - * you do include it, it must appear in lowercase at the start of the string, or the - * request is rejected. + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added + * automatically if missing, and validated if present. Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt index c0414927..8687b314 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -31,15 +31,12 @@ interface NamedTransformationServiceAsync { /** * Creates a new named transformation and returns the created object. * - * Named transformations let you assign a short, reusable name to a complex transformation - * string, so it can be applied in image and video URLs as `tr:n-` and later updated - * without changing any existing URLs. - * - * Learn more about + * A named transformation is a short, reusable name for a transformation string. Use it in image + * and video URLs as `tr:n-`, and update the underlying transformation later without + * changing existing URLs. Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). * - * **Note:** You can create up to 250 named transformations per account. Once this limit is - * reached, the request fails with a `400` error. + * You can create up to 250 named transformations per account. */ fun create(params: NamedTransformationCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -52,16 +49,13 @@ interface NamedTransformationServiceAsync { /** * Updates the named transformation identified by `id` and returns the updated object. Only the - * fields present in the request body are updated; omitted fields are left unchanged. + * fields present in the request body are updated; other fields stay unchanged. * - * **Note:** - * - If you rename this named transformation, or set `enabled` to `false`, and another *enabled* - * named transformation, or your account's upload pre-transformation/post-transformation - * settings, reference it (via the `n-` token), the request fails with a `409` error - * whose `message` describes what it is referenced by. A reference from a named transformation - * that is itself disabled does not block this request. Remove or disable those references - * first, then retry. This is a best-effort check and cannot detect references baked into your - * own application code or previously generated URLs. + * Renaming or disabling a named transformation fails with a `409` error if it is still + * referenced (via the `n-` token) by another enabled named transformation, or by an + * upload pre-transformation/post-transformation setting. References from disabled named + * transformations don't count. This check is best-effort and can't detect references in your + * own application code or in previously generated URLs. */ fun update(id: String): CompletableFuture = update(id, NamedTransformationUpdateParams.none()) @@ -117,14 +111,11 @@ interface NamedTransformationServiceAsync { * Permanently deletes the named transformation identified by `id` and returns the deleted * object. * - * **Note:** - * - If another *enabled* named transformation, or your account's upload - * pre-transformation/post-transformation settings, reference this named transformation (via - * the `n-` token), the request fails with a `409` error whose `message` describes what - * it is referenced by. A reference from a named transformation that is itself disabled does - * not block this request. Remove or disable those references first, then retry the deletion. - * This is a best-effort check and cannot detect references baked into your own application - * code or previously generated URLs. + * Deletion fails with a `409` error if the named transformation is still referenced (via the + * `n-` token) by another enabled named transformation, or by an upload + * pre-transformation/post-transformation setting. References from disabled named + * transformations don't count. This check is best-effort and can't detect references in your + * own application code or in previously generated URLs. */ fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt index 94089280..86989f2e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -31,15 +31,12 @@ interface NamedTransformationService { /** * Creates a new named transformation and returns the created object. * - * Named transformations let you assign a short, reusable name to a complex transformation - * string, so it can be applied in image and video URLs as `tr:n-` and later updated - * without changing any existing URLs. - * - * Learn more about + * A named transformation is a short, reusable name for a transformation string. Use it in image + * and video URLs as `tr:n-`, and update the underlying transformation later without + * changing existing URLs. Learn more about * [named transformations](https://imagekit.io/docs/transformations#named-transformations). * - * **Note:** You can create up to 250 named transformations per account. Once this limit is - * reached, the request fails with a `400` error. + * You can create up to 250 named transformations per account. */ fun create(params: NamedTransformationCreateParams): NamedTransformation = create(params, RequestOptions.none()) @@ -52,16 +49,13 @@ interface NamedTransformationService { /** * Updates the named transformation identified by `id` and returns the updated object. Only the - * fields present in the request body are updated; omitted fields are left unchanged. + * fields present in the request body are updated; other fields stay unchanged. * - * **Note:** - * - If you rename this named transformation, or set `enabled` to `false`, and another *enabled* - * named transformation, or your account's upload pre-transformation/post-transformation - * settings, reference it (via the `n-` token), the request fails with a `409` error - * whose `message` describes what it is referenced by. A reference from a named transformation - * that is itself disabled does not block this request. Remove or disable those references - * first, then retry. This is a best-effort check and cannot detect references baked into your - * own application code or previously generated URLs. + * Renaming or disabling a named transformation fails with a `409` error if it is still + * referenced (via the `n-` token) by another enabled named transformation, or by an + * upload pre-transformation/post-transformation setting. References from disabled named + * transformations don't count. This check is best-effort and can't detect references in your + * own application code or in previously generated URLs. */ fun update(id: String): NamedTransformation = update(id, NamedTransformationUpdateParams.none()) @@ -114,14 +108,11 @@ interface NamedTransformationService { * Permanently deletes the named transformation identified by `id` and returns the deleted * object. * - * **Note:** - * - If another *enabled* named transformation, or your account's upload - * pre-transformation/post-transformation settings, reference this named transformation (via - * the `n-` token), the request fails with a `409` error whose `message` describes what - * it is referenced by. A reference from a named transformation that is itself disabled does - * not block this request. Remove or disable those references first, then retry the deletion. - * This is a best-effort check and cannot detect references baked into your own application - * code or previously generated URLs. + * Deletion fails with a `409` error if the named transformation is still referenced (via the + * `n-` token) by another enabled named transformation, or by an upload + * pre-transformation/post-transformation setting. References from disabled named + * transformations don't count. This check is best-effort and can't detect references in your + * own application code or in previously generated URLs. */ fun delete(id: String): NamedTransformation = delete(id, NamedTransformationDeleteParams.none()) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt index 103478ed..5aec18b9 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt @@ -12,7 +12,7 @@ internal class NamedTransformationUpdateParamsTest { NamedTransformationUpdateParams.builder() .id("id") .enabled(true) - .name("small_thumbnail_v2") + .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() } @@ -32,14 +32,14 @@ internal class NamedTransformationUpdateParamsTest { NamedTransformationUpdateParams.builder() .id("id") .enabled(true) - .name("small_thumbnail_v2") + .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() val body = params._body() assertThat(body.enabled()).contains(true) - assertThat(body.name()).contains("small_thumbnail_v2") + assertThat(body.name()).contains("small_thumbnail") assertThat(body.transformation()).contains("w-200,h-200,fo-center,cm-resize") } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt index 9c63105b..200934d1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -48,7 +48,7 @@ internal class NamedTransformationServiceAsyncTest { NamedTransformationUpdateParams.builder() .id("id") .enabled(true) - .name("small_thumbnail_v2") + .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt index 17fede86..fcecc2b6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -47,7 +47,7 @@ internal class NamedTransformationServiceTest { NamedTransformationUpdateParams.builder() .id("id") .enabled(true) - .name("small_thumbnail_v2") + .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() ) From e24d49e63e40eb2c56d3f47aa4edc5b8c8cf2b8a Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Wed, 12 Aug 2026 08:45:03 +0000 Subject: [PATCH 05/10] Build SDK Stainless-Generated-From: f4e30554f36ab8595ac1edef5d847b9b44199879 --- .../NamedTransformationCreateParams.kt | 18 ++++++++----- .../NamedTransformationDeleteParams.kt | 7 +++--- .../NamedTransformationUpdateParams.kt | 25 +++++++++++-------- .../async/NamedTransformationServiceAsync.kt | 14 +++++------ .../blocking/NamedTransformationService.kt | 14 +++++------ 5 files changed, 42 insertions(+), 36 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt index 28abb76e..87a8e2c8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -49,7 +49,9 @@ private constructor( /** * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. * The `tr:` prefix is optional — it's added automatically if missing, and validated if present. - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * The string must be a valid ImageKit transformation and cannot itself reference another named + * transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -156,8 +158,9 @@ private constructor( /** * The transformation string this name refers to, for example * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * automatically if missing, and validated if present. The string must be a valid ImageKit + * transformation and cannot itself reference another named transformation (no nesting). + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -361,8 +364,9 @@ private constructor( /** * The transformation string this name refers to, for example * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * automatically if missing, and validated if present. The string must be a valid ImageKit + * transformation and cannot itself reference another named transformation (no nesting). + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -463,7 +467,9 @@ private constructor( /** * The transformation string this name refers to, for example * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. Learn more about the + * automatically if missing, and validated if present. The string must be a valid + * ImageKit transformation and cannot itself reference another named transformation (no + * nesting). Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt index 574308e4..f1250f84 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -15,10 +15,9 @@ import kotlin.jvm.optionals.getOrNull * Permanently deletes the named transformation identified by `id` and returns the deleted object. * * Deletion fails with a `409` error if the named transformation is still referenced (via the - * `n-` token) by another enabled named transformation, or by an upload - * pre-transformation/post-transformation setting. References from disabled named transformations - * don't count. This check is best-effort and can't detect references in your own application code - * or in previously generated URLs. + * `n-` token) by an upload pre-transformation or post-transformation setting. This check is + * best-effort and can't detect references in your own application code or in previously generated + * URLs. */ class NamedTransformationDeleteParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt index 5089720c..be10936e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -24,10 +24,9 @@ import kotlin.jvm.optionals.getOrNull * fields present in the request body are updated; other fields stay unchanged. * * Renaming or disabling a named transformation fails with a `409` error if it is still referenced - * (via the `n-` token) by another enabled named transformation, or by an upload - * pre-transformation/post-transformation setting. References from disabled named transformations - * don't count. This check is best-effort and can't detect references in your own application code - * or in previously generated URLs. + * (via the `n-` token) by an upload pre-transformation or post-transformation setting. This + * check is best-effort and can't detect references in your own application code or in previously + * generated URLs. */ class NamedTransformationUpdateParams private constructor( @@ -60,7 +59,9 @@ private constructor( /** * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. * The `tr:` prefix is optional — it's added automatically if missing, and validated if present. - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * The string must be a valid ImageKit transformation and cannot itself reference another named + * transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -174,8 +175,9 @@ private constructor( /** * The transformation string this name refers to, for example * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * automatically if missing, and validated if present. The string must be a valid ImageKit + * transformation and cannot itself reference another named transformation (no nesting). + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -372,8 +374,9 @@ private constructor( /** * The transformation string this name refers to, for example * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * automatically if missing, and validated if present. The string must be a valid ImageKit + * transformation and cannot itself reference another named transformation (no nesting). + * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -472,7 +475,9 @@ private constructor( /** * The transformation string this name refers to, for example * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. Learn more about the + * automatically if missing, and validated if present. The string must be a valid + * ImageKit transformation and cannot itself reference another named transformation (no + * nesting). Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt index 8687b314..4e3afb67 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -52,10 +52,9 @@ interface NamedTransformationServiceAsync { * fields present in the request body are updated; other fields stay unchanged. * * Renaming or disabling a named transformation fails with a `409` error if it is still - * referenced (via the `n-` token) by another enabled named transformation, or by an - * upload pre-transformation/post-transformation setting. References from disabled named - * transformations don't count. This check is best-effort and can't detect references in your - * own application code or in previously generated URLs. + * referenced (via the `n-` token) by an upload pre-transformation or post-transformation + * setting. This check is best-effort and can't detect references in your own application code + * or in previously generated URLs. */ fun update(id: String): CompletableFuture = update(id, NamedTransformationUpdateParams.none()) @@ -112,10 +111,9 @@ interface NamedTransformationServiceAsync { * object. * * Deletion fails with a `409` error if the named transformation is still referenced (via the - * `n-` token) by another enabled named transformation, or by an upload - * pre-transformation/post-transformation setting. References from disabled named - * transformations don't count. This check is best-effort and can't detect references in your - * own application code or in previously generated URLs. + * `n-` token) by an upload pre-transformation or post-transformation setting. This check + * is best-effort and can't detect references in your own application code or in previously + * generated URLs. */ fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt index 86989f2e..ac78b7db 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -52,10 +52,9 @@ interface NamedTransformationService { * fields present in the request body are updated; other fields stay unchanged. * * Renaming or disabling a named transformation fails with a `409` error if it is still - * referenced (via the `n-` token) by another enabled named transformation, or by an - * upload pre-transformation/post-transformation setting. References from disabled named - * transformations don't count. This check is best-effort and can't detect references in your - * own application code or in previously generated URLs. + * referenced (via the `n-` token) by an upload pre-transformation or post-transformation + * setting. This check is best-effort and can't detect references in your own application code + * or in previously generated URLs. */ fun update(id: String): NamedTransformation = update(id, NamedTransformationUpdateParams.none()) @@ -109,10 +108,9 @@ interface NamedTransformationService { * object. * * Deletion fails with a `409` error if the named transformation is still referenced (via the - * `n-` token) by another enabled named transformation, or by an upload - * pre-transformation/post-transformation setting. References from disabled named - * transformations don't count. This check is best-effort and can't detect references in your - * own application code or in previously generated URLs. + * `n-` token) by an upload pre-transformation or post-transformation setting. This check + * is best-effort and can't detect references in your own application code or in previously + * generated URLs. */ fun delete(id: String): NamedTransformation = delete(id, NamedTransformationDeleteParams.none()) From e0793747a49c247477995171982a36742f20f8ae Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 13 Aug 2026 08:31:15 +0000 Subject: [PATCH 06/10] Build SDK Stainless-Generated-From: 4416676f4b8d123b0dea49ac6b36b4c9a02d7a28 --- .../io/imagekit/models/NamedTransformation.kt | 36 +++-- .../CustomMetadataField.kt | 51 ++++++- .../CustomMetadataFieldCreateParams.kt | 89 +++++++++++- .../CustomMetadataFieldUpdateParams.kt | 95 ++++++++++++- .../NamedTransformationCreateParams.kt | 45 +++--- .../NamedTransformationDeleteParams.kt | 4 +- .../NamedTransformationDeleteResponse.kt | 129 ++++++++++++++++++ .../NamedTransformationGetParams.kt | 2 + .../NamedTransformationUpdateParams.kt | 31 +++-- .../async/CustomMetadataFieldServiceAsync.kt | 2 +- .../async/NamedTransformationServiceAsync.kt | 37 +++-- .../NamedTransformationServiceAsyncImpl.kt | 9 +- .../blocking/CustomMetadataFieldService.kt | 2 +- .../blocking/NamedTransformationService.kt | 32 +++-- .../NamedTransformationServiceImpl.kt | 9 +- .../models/NamedTransformationTest.kt | 7 +- .../CustomMetadataFieldCreateParamsTest.kt | 3 + .../CustomMetadataFieldTest.kt | 3 + .../CustomMetadataFieldUpdateParamsTest.kt | 3 + .../NamedTransformationDeleteParamsTest.kt | 6 +- .../NamedTransformationDeleteResponseTest.kt | 31 +++++ .../NamedTransformationGetParamsTest.kt | 6 +- .../NamedTransformationUpdateParamsTest.kt | 16 +-- .../CustomMetadataFieldServiceAsyncTest.kt | 2 + .../NamedTransformationServiceAsyncTest.kt | 8 +- .../CustomMetadataFieldServiceTest.kt | 2 + .../NamedTransformationServiceTest.kt | 8 +- 27 files changed, 540 insertions(+), 128 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt create mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt index 4619fb20..15dc9916 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -46,7 +46,7 @@ private constructor( ) : this(id, createdAt, enabled, name, transformation, mutableMapOf()) /** - * Unique identifier generated by ImageKit when the named transformation was created. + * Unique identifier for a named transformation. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -62,7 +62,8 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether the named transformation is currently enabled. + * Whether the named transformation is currently enabled. When this is set to `false`, requests + * using such disabled named transformations fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -70,7 +71,9 @@ private constructor( fun enabled(): Optional = enabled.getOptional("enabled") /** - * Name of the named transformation, used as `tr:n-` in image and video URLs. + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name matching is + * case-sensitive. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -78,8 +81,11 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * Transformation string this name refers to. Always includes the `tr:` prefix, even if you - * omitted it in the request. + * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. + * The `tr:` prefix is optional; if present, it is validated. The string must be a valid + * ImageKit transformation and cannot itself reference another named transformation (no + * nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -163,7 +169,7 @@ private constructor( additionalProperties = namedTransformation.additionalProperties.toMutableMap() } - /** Unique identifier generated by ImageKit when the named transformation was created. */ + /** Unique identifier for a named transformation. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -186,7 +192,10 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether the named transformation is currently enabled. */ + /** + * Whether the named transformation is currently enabled. When this is set to `false`, + * requests using such disabled named transformations fail at delivery time. + */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) /** @@ -197,7 +206,11 @@ private constructor( */ fun enabled(enabled: JsonField) = apply { this.enabled = enabled } - /** Name of the named transformation, used as `tr:n-` in image and video URLs. */ + /** + * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only + * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name + * matching is case-sensitive. + */ fun name(name: String) = name(JsonField.of(name)) /** @@ -209,8 +222,11 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * Transformation string this name refers to. Always includes the `tr:` prefix, even if you - * omitted it in the request. + * The transformation string this name refers to, for example + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself reference + * another named transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt index cbda2b69..6381c481 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt @@ -39,6 +39,7 @@ private constructor( private val label: JsonField, private val name: JsonField, private val schema: JsonField, + private val description: JsonField, private val additionalProperties: MutableMap, ) { @@ -48,7 +49,10 @@ private constructor( @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("schema") @ExcludeMissing schema: JsonField = JsonMissing.of(), - ) : this(id, label, name, schema, mutableMapOf()) + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this(id, label, name, schema, description, mutableMapOf()) /** * Unique identifier for the custom metadata field. Use this to update the field. @@ -84,6 +88,16 @@ private constructor( */ fun schema(): Schema = schema.getRequired("schema") + /** + * Optional description of the custom metadata field. Only present when a description has been + * set. Shown as a hint to the users while setting the field's value on an asset in the media + * library UI. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + /** * Returns the raw JSON value of [id]. * @@ -112,6 +126,13 @@ private constructor( */ @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonField = schema + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -147,6 +168,7 @@ private constructor( private var label: JsonField? = null private var name: JsonField? = null private var schema: JsonField? = null + private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -155,6 +177,7 @@ private constructor( label = customMetadataField.label name = customMetadataField.name schema = customMetadataField.schema + description = customMetadataField.description additionalProperties = customMetadataField.additionalProperties.toMutableMap() } @@ -208,6 +231,22 @@ private constructor( */ fun schema(schema: JsonField) = apply { this.schema = schema } + /** + * Optional description of the custom metadata field. Only present when a description has + * been set. Shown as a hint to the users while setting the field's value on an asset in the + * media library UI. + */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -248,6 +287,7 @@ private constructor( checkRequired("label", label), checkRequired("name", name), checkRequired("schema", schema), + description, additionalProperties.toMutableMap(), ) } @@ -271,6 +311,7 @@ private constructor( label() name() schema().validate() + description() validated = true } @@ -292,7 +333,8 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (label.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (schema.asKnown().getOrNull()?.validity() ?: 0) + (schema.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) /** An object that describes the rules for the custom metadata field value. */ class Schema @@ -2185,15 +2227,16 @@ private constructor( label == other.label && name == other.name && schema == other.schema && + description == other.description && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, label, name, schema, additionalProperties) + Objects.hash(id, label, name, schema, description, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "CustomMetadataField{id=$id, label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" + "CustomMetadataField{id=$id, label=$label, name=$name, schema=$schema, description=$description, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index aa69f84a..c31d5f5a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -72,6 +72,16 @@ private constructor( */ fun schema(): Schema = body.schema() + /** + * Optional description for the custom metadata field. Can be up to 500 characters. This is + * shown as a hint to the users while setting the field's value on an asset in the media library + * UI. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + /** * Returns the raw JSON value of [label]. * @@ -93,6 +103,13 @@ private constructor( */ fun _schema(): JsonField = body._schema() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -143,6 +160,7 @@ private constructor( * - [label] * - [name] * - [schema] + * - [description] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -185,6 +203,22 @@ private constructor( */ fun schema(schema: JsonField) = apply { body.schema(schema) } + /** + * Optional description for the custom metadata field. Can be up to 500 characters. This is + * shown as a hint to the users while setting the field's value on an asset in the media + * library UI. + */ + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -336,6 +370,7 @@ private constructor( private val label: JsonField, private val name: JsonField, private val schema: JsonField, + private val description: JsonField, private val additionalProperties: MutableMap, ) { @@ -344,7 +379,10 @@ private constructor( @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("schema") @ExcludeMissing schema: JsonField = JsonMissing.of(), - ) : this(label, name, schema, mutableMapOf()) + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this(label, name, schema, description, mutableMapOf()) /** * Human readable name of the custom metadata field. This should be unique across all non @@ -371,6 +409,16 @@ private constructor( */ fun schema(): Schema = schema.getRequired("schema") + /** + * Optional description for the custom metadata field. Can be up to 500 characters. This is + * shown as a hint to the users while setting the field's value on an asset in the media + * library UI. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + /** * Returns the raw JSON value of [label]. * @@ -392,6 +440,15 @@ private constructor( */ @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonField = schema + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -425,6 +482,7 @@ private constructor( private var label: JsonField? = null private var name: JsonField? = null private var schema: JsonField? = null + private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -432,6 +490,7 @@ private constructor( label = body.label name = body.name schema = body.schema + description = body.description additionalProperties = body.additionalProperties.toMutableMap() } @@ -477,6 +536,24 @@ private constructor( */ fun schema(schema: JsonField) = apply { this.schema = schema } + /** + * Optional description for the custom metadata field. Can be up to 500 characters. This + * is shown as a hint to the users while setting the field's value on an asset in the + * media library UI. + */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -515,6 +592,7 @@ private constructor( checkRequired("label", label), checkRequired("name", name), checkRequired("schema", schema), + description, additionalProperties.toMutableMap(), ) } @@ -538,6 +616,7 @@ private constructor( label() name() schema().validate() + description() validated = true } @@ -559,7 +638,8 @@ private constructor( internal fun validity(): Int = (if (label.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (schema.asKnown().getOrNull()?.validity() ?: 0) + (schema.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -570,17 +650,18 @@ private constructor( label == other.label && name == other.name && schema == other.schema && + description == other.description && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(label, name, schema, additionalProperties) + Objects.hash(label, name, schema, description, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" + "Body{label=$label, name=$name, schema=$schema, description=$description, additionalProperties=$additionalProperties}" } class Schema diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index 2854e1df..4fa72756 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -32,7 +32,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** This API updates the label or schema of an existing custom metadata field. */ +/** This API updates the label, description, or schema of an existing custom metadata field. */ class CustomMetadataFieldUpdateParams private constructor( private val id: String?, @@ -43,6 +43,16 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) + /** + * Optional description for the custom metadata field. Can be up to 500 characters. Send an + * empty string to clear an existing description. This is shown as a hint to the users while + * setting the field's value on an asset in the media library UI. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + /** * Human readable name of the custom metadata field. This should be unique across all non * deleted custom metadata fields. This name is displayed as form field label to the users while @@ -64,6 +74,13 @@ private constructor( */ fun schema(): Optional = body.schema() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + /** * Returns the raw JSON value of [label]. * @@ -127,11 +144,28 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] * - [label] * - [schema] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** + * Optional description for the custom metadata field. Can be up to 500 characters. Send an + * empty string to clear an existing description. This is shown as a hint to the users while + * setting the field's value on an asset in the media library UI. + */ + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + /** * Human readable name of the custom metadata field. This should be unique across all non * deleted custom metadata fields. This name is displayed as form field label to the users @@ -309,6 +343,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val description: JsonField, private val label: JsonField, private val schema: JsonField, private val additionalProperties: MutableMap, @@ -316,9 +351,22 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), @JsonProperty("schema") @ExcludeMissing schema: JsonField = JsonMissing.of(), - ) : this(label, schema, mutableMapOf()) + ) : this(description, label, schema, mutableMapOf()) + + /** + * Optional description for the custom metadata field. Can be up to 500 characters. Send an + * empty string to clear an existing description. This is shown as a hint to the users while + * setting the field's value on an asset in the media library UI. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") /** * Human readable name of the custom metadata field. This should be unique across all non @@ -341,6 +389,15 @@ private constructor( */ fun schema(): Optional = schema.getOptional("schema") + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + /** * Returns the raw JSON value of [label]. * @@ -376,17 +433,37 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var description: JsonField = JsonMissing.of() private var label: JsonField = JsonMissing.of() private var schema: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + description = body.description label = body.label schema = body.schema additionalProperties = body.additionalProperties.toMutableMap() } + /** + * Optional description for the custom metadata field. Can be up to 500 characters. Send + * an empty string to clear an existing description. This is shown as a hint to the + * users while setting the field's value on an asset in the media library UI. + */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * Human readable name of the custom metadata field. This should be unique across all * non deleted custom metadata fields. This name is displayed as form field label to the @@ -445,7 +522,8 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(label, schema, additionalProperties.toMutableMap()) + fun build(): Body = + Body(description, label, schema, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -464,6 +542,7 @@ private constructor( return@apply } + description() label() schema().ifPresent { it.validate() } validated = true @@ -485,7 +564,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (label.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (label.asKnown().isPresent) 1 else 0) + (schema.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -494,17 +574,20 @@ private constructor( } return other is Body && + description == other.description && label == other.label && schema == other.schema && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(label, schema, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(description, label, schema, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{label=$label, schema=$schema, additionalProperties=$additionalProperties}" + "Body{description=$description, label=$label, schema=$schema, additionalProperties=$additionalProperties}" } /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt index 87a8e2c8..951a94b5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -48,9 +48,9 @@ private constructor( /** * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. - * The `tr:` prefix is optional — it's added automatically if missing, and validated if present. - * The string must be a valid ImageKit transformation and cannot itself reference another named - * transformation (no nesting). Learn more about the + * The `tr:` prefix is optional; if present, it is validated. The string must be a valid + * ImageKit transformation and cannot itself reference another named transformation (no + * nesting). Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -59,8 +59,8 @@ private constructor( fun transformation(): String = body.transformation() /** - * Whether the named transformation is enabled. Set to `false` to disable it without deleting - * it; requests using a disabled named transformation fail at delivery time. + * Whether the named transformation is currently enabled. When this is set to `false`, requests + * using such disabled named transformations fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -157,10 +157,10 @@ private constructor( /** * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. The string must be a valid ImageKit - * transformation and cannot itself reference another named transformation (no nesting). - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself reference + * another named transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -176,8 +176,8 @@ private constructor( } /** - * Whether the named transformation is enabled. Set to `false` to disable it without - * deleting it; requests using a disabled named transformation fail at delivery time. + * Whether the named transformation is currently enabled. When this is set to `false`, + * requests using such disabled named transformations fail at delivery time. */ fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } @@ -363,10 +363,10 @@ private constructor( /** * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. The string must be a valid ImageKit - * transformation and cannot itself reference another named transformation (no nesting). - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself reference + * another named transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @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). @@ -374,8 +374,8 @@ private constructor( fun transformation(): String = transformation.getRequired("transformation") /** - * Whether the named transformation is enabled. Set to `false` to disable it without - * deleting it; requests using a disabled named transformation fail at delivery time. + * Whether the named transformation is currently enabled. When this is set to `false`, + * requests using such disabled named transformations fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -466,10 +466,9 @@ private constructor( /** * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. The string must be a valid - * ImageKit transformation and cannot itself reference another named transformation (no - * nesting). Learn more about the + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself + * reference another named transformation (no nesting). Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = @@ -487,8 +486,8 @@ private constructor( } /** - * Whether the named transformation is enabled. Set to `false` to disable it without - * deleting it; requests using a disabled named transformation fail at delivery time. + * Whether the named transformation is currently enabled. When this is set to `false`, + * requests using such disabled named transformations fail at delivery time. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt index f1250f84..3e7b9cbb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -12,7 +12,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Permanently deletes the named transformation identified by `id` and returns the deleted object. + * Permanently deletes the named transformation identified by `id`. * * Deletion fails with a `409` error if the named transformation is still referenced (via the * `n-` token) by an upload pre-transformation or post-transformation setting. This check is @@ -27,6 +27,7 @@ private constructor( private val additionalBodyProperties: Map, ) : Params { + /** Unique identifier for a named transformation. */ fun id(): Optional = Optional.ofNullable(id) /** Additional body properties to send with the request. */ @@ -70,6 +71,7 @@ private constructor( namedTransformationDeleteParams.additionalBodyProperties.toMutableMap() } + /** Unique identifier for a named transformation. */ fun id(id: String?) = apply { this.id = id } /** Alias for calling [Builder.id] with `id.orElse(null)`. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt new file mode 100644 index 00000000..03229d36 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class NamedTransformationDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NamedTransformationDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NamedTransformationDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(namedTransformationDeleteResponse: NamedTransformationDeleteResponse) = + apply { + additionalProperties = + namedTransformationDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NamedTransformationDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NamedTransformationDeleteResponse = + NamedTransformationDeleteResponse(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(): NamedTransformationDeleteResponse = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NamedTransformationDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NamedTransformationDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt index cb89808c..3069e5af 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt @@ -17,6 +17,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** Unique identifier for a named transformation. */ fun id(): Optional = Optional.ofNullable(id) /** Additional headers to send with the request. */ @@ -51,6 +52,7 @@ private constructor( additionalQueryParams = namedTransformationGetParams.additionalQueryParams.toBuilder() } + /** Unique identifier for a named transformation. */ fun id(id: String?) = apply { this.id = id } /** Alias for calling [Builder.id] with `id.orElse(null)`. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt index be10936e..94b67e4b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -36,6 +36,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** Unique identifier for a named transformation. */ fun id(): Optional = Optional.ofNullable(id) /** @@ -58,9 +59,9 @@ private constructor( /** * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. - * The `tr:` prefix is optional — it's added automatically if missing, and validated if present. - * The string must be a valid ImageKit transformation and cannot itself reference another named - * transformation (no nesting). Learn more about the + * The `tr:` prefix is optional; if present, it is validated. The string must be a valid + * ImageKit transformation and cannot itself reference another named transformation (no + * nesting). Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -128,6 +129,7 @@ private constructor( namedTransformationUpdateParams.additionalQueryParams.toBuilder() } + /** Unique identifier for a named transformation. */ fun id(id: String?) = apply { this.id = id } /** Alias for calling [Builder.id] with `id.orElse(null)`. */ @@ -174,10 +176,10 @@ private constructor( /** * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. The string must be a valid ImageKit - * transformation and cannot itself reference another named transformation (no nesting). - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself reference + * another named transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -373,10 +375,10 @@ private constructor( /** * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. The string must be a valid ImageKit - * transformation and cannot itself reference another named transformation (no nesting). - * Learn more about the [transformation syntax](https://imagekit.io/docs/transformations). + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself reference + * another named transformation (no nesting). Learn more about the + * [transformation syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -474,10 +476,9 @@ private constructor( /** * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional — it's added - * automatically if missing, and validated if present. The string must be a valid - * ImageKit transformation and cannot itself reference another named transformation (no - * nesting). Learn more about the + * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is + * validated. The string must be a valid ImageKit transformation and cannot itself + * reference another named transformation (no nesting). Learn more about the * [transformation syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt index 82398fc8..0d23e870 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt @@ -43,7 +43,7 @@ interface CustomMetadataFieldServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** This API updates the label or schema of an existing custom metadata field. */ + /** This API updates the label, description, or schema of an existing custom metadata field. */ fun update(id: String): CompletableFuture = update(id, CustomMetadataFieldUpdateParams.none()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt index 4e3afb67..b6eb3bf5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -8,6 +8,7 @@ import io.imagekit.core.http.HttpResponseFor import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -107,15 +108,14 @@ interface NamedTransformationServiceAsync { list(NamedTransformationListParams.none(), requestOptions) /** - * Permanently deletes the named transformation identified by `id` and returns the deleted - * object. + * Permanently deletes the named transformation identified by `id`. * * Deletion fails with a `409` error if the named transformation is still referenced (via the * `n-` token) by an upload pre-transformation or post-transformation setting. This check * is best-effort and can't detect references in your own application code or in previously * generated URLs. */ - fun delete(id: String): CompletableFuture = + fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ @@ -123,27 +123,32 @@ interface NamedTransformationServiceAsync { id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): CompletableFuture = delete(id, params, RequestOptions.none()) + ): CompletableFuture = + delete(id, params, RequestOptions.none()) /** @see delete */ fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see delete */ - fun delete(params: NamedTransformationDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete( + params: NamedTransformationDeleteParams + ): CompletableFuture = delete(params, RequestOptions.none()) /** @see delete */ - fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** Retrieves the named transformation identified by `id`. */ @@ -278,7 +283,9 @@ interface NamedTransformationServiceAsync { * Returns a raw HTTP response for `delete /v1/named-transformations/{id}`, but is otherwise * the same as [NamedTransformationServiceAsync.delete]. */ - fun delete(id: String): CompletableFuture> = + fun delete( + id: String + ): CompletableFuture> = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ @@ -286,33 +293,33 @@ interface NamedTransformationServiceAsync { id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = delete(id, params, RequestOptions.none()) /** @see delete */ fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see delete */ fun delete( params: NamedTransformationDeleteParams - ): CompletableFuture> = + ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see delete */ fun delete( id: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt index 435db72b..396ff03e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import io.imagekit.core.prepareAsync import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -67,7 +68,7 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // delete /v1/named-transformations/{id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } @@ -186,13 +187,13 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt index c00aa0c4..ff9104ef 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt @@ -43,7 +43,7 @@ interface CustomMetadataFieldService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomMetadataField - /** This API updates the label or schema of an existing custom metadata field. */ + /** This API updates the label, description, or schema of an existing custom metadata field. */ fun update(id: String): CustomMetadataField = update(id, CustomMetadataFieldUpdateParams.none()) /** @see update */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt index ac78b7db..c647d3b1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -9,6 +9,7 @@ import io.imagekit.core.http.HttpResponseFor import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -104,41 +105,41 @@ interface NamedTransformationService { list(NamedTransformationListParams.none(), requestOptions) /** - * Permanently deletes the named transformation identified by `id` and returns the deleted - * object. + * Permanently deletes the named transformation identified by `id`. * * Deletion fails with a `409` error if the named transformation is still referenced (via the * `n-` token) by an upload pre-transformation or post-transformation setting. This check * is best-effort and can't detect references in your own application code or in previously * generated URLs. */ - fun delete(id: String): NamedTransformation = delete(id, NamedTransformationDeleteParams.none()) + fun delete(id: String): NamedTransformationDeleteResponse = + delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): NamedTransformation = delete(params.toBuilder().id(id).build(), requestOptions) + ): NamedTransformationDeleteResponse = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): NamedTransformation = delete(id, params, RequestOptions.none()) + ): NamedTransformationDeleteResponse = delete(id, params, RequestOptions.none()) /** @see delete */ fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): NamedTransformation + ): NamedTransformationDeleteResponse /** @see delete */ - fun delete(params: NamedTransformationDeleteParams): NamedTransformation = + fun delete(params: NamedTransformationDeleteParams): NamedTransformationDeleteResponse = delete(params, RequestOptions.none()) /** @see delete */ - fun delete(id: String, requestOptions: RequestOptions): NamedTransformation = + fun delete(id: String, requestOptions: RequestOptions): NamedTransformationDeleteResponse = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** Retrieves the named transformation identified by `id`. */ @@ -276,7 +277,7 @@ interface NamedTransformationService { * the same as [NamedTransformationService.delete]. */ @MustBeClosed - fun delete(id: String): HttpResponseFor = + fun delete(id: String): HttpResponseFor = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ @@ -285,7 +286,7 @@ interface NamedTransformationService { id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ @@ -293,18 +294,21 @@ interface NamedTransformationService { fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): HttpResponseFor = delete(id, params, RequestOptions.none()) + ): HttpResponseFor = + delete(id, params, RequestOptions.none()) /** @see delete */ @MustBeClosed fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see delete */ @MustBeClosed - fun delete(params: NamedTransformationDeleteParams): HttpResponseFor = + fun delete( + params: NamedTransformationDeleteParams + ): HttpResponseFor = delete(params, RequestOptions.none()) /** @see delete */ @@ -312,7 +316,7 @@ interface NamedTransformationService { fun delete( id: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt index cbd0929d..68040f2c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt @@ -19,6 +19,7 @@ import io.imagekit.core.prepare import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams +import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -63,7 +64,7 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): NamedTransformation = + ): NamedTransformationDeleteResponse = // delete /v1/named-transformations/{id} withRawResponse().delete(params, requestOptions).parse() @@ -173,13 +174,13 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt index a8507f8a..ea9fcc65 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt @@ -18,7 +18,7 @@ internal class NamedTransformationTest { .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) .enabled(true) .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-resize") .build() assertThat(namedTransformation.id()).contains("6bZ9x2ZUx") @@ -26,8 +26,7 @@ internal class NamedTransformationTest { .contains(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) assertThat(namedTransformation.enabled()).contains(true) assertThat(namedTransformation.name()).contains("small_thumbnail") - assertThat(namedTransformation.transformation()) - .contains("tr:w-150,h-150,fo-center,cm-resize") + assertThat(namedTransformation.transformation()).contains("w-150,h-150,fo-center,cm-resize") } @Test @@ -39,7 +38,7 @@ internal class NamedTransformationTest { .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) .enabled(true) .name("small_thumbnail") - .transformation("tr:w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-resize") .build() val roundtrippedNamedTransformation = diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt index 092fc696..c612823d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -42,6 +42,7 @@ internal class CustomMetadataFieldCreateParamsTest { ) .build() ) + .description("description") .build() } @@ -87,6 +88,7 @@ internal class CustomMetadataFieldCreateParamsTest { ) .build() ) + .description("description") .build() val body = params._body() @@ -124,6 +126,7 @@ internal class CustomMetadataFieldCreateParamsTest { ) .build() ) + assertThat(body.description()).contains("description") } @Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt index 618813d4..262548f8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -49,6 +49,7 @@ internal class CustomMetadataFieldTest { ) .build() ) + .description("description") .build() assertThat(customMetadataField.id()).isEqualTo("id") @@ -84,6 +85,7 @@ internal class CustomMetadataFieldTest { ) .build() ) + assertThat(customMetadataField.description()).contains("description") } @Test @@ -127,6 +129,7 @@ internal class CustomMetadataFieldTest { ) .build() ) + .description("description") .build() val roundtrippedCustomMetadataField = diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt index dc99c64d..50e12e26 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -11,6 +11,7 @@ internal class CustomMetadataFieldUpdateParamsTest { fun create() { CustomMetadataFieldUpdateParams.builder() .id("id") + .description("description") .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() @@ -58,6 +59,7 @@ internal class CustomMetadataFieldUpdateParamsTest { val params = CustomMetadataFieldUpdateParams.builder() .id("id") + .description("description") .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() @@ -98,6 +100,7 @@ internal class CustomMetadataFieldUpdateParamsTest { val body = params._body() + assertThat(body.description()).contains("description") assertThat(body.label()).contains("price") assertThat(body.schema()) .contains( diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt index 6d008c14..035befdc 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParamsTest.kt @@ -9,14 +9,14 @@ internal class NamedTransformationDeleteParamsTest { @Test fun create() { - NamedTransformationDeleteParams.builder().id("id").build() + NamedTransformationDeleteParams.builder().id("6bZ9x2ZUx").build() } @Test fun pathParams() { - val params = NamedTransformationDeleteParams.builder().id("id").build() + val params = NamedTransformationDeleteParams.builder().id("6bZ9x2ZUx").build() - assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(0)).isEqualTo("6bZ9x2ZUx") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt new file mode 100644 index 00000000..fa89a927 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package io.imagekit.models.namedtransformations + +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 NamedTransformationDeleteResponseTest { + + @Test + fun create() { + val namedTransformationDeleteResponse = NamedTransformationDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val namedTransformationDeleteResponse = NamedTransformationDeleteResponse.builder().build() + + val roundtrippedNamedTransformationDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(namedTransformationDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNamedTransformationDeleteResponse) + .isEqualTo(namedTransformationDeleteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt index bb8fabec..1b7ba85f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt @@ -9,14 +9,14 @@ internal class NamedTransformationGetParamsTest { @Test fun create() { - NamedTransformationGetParams.builder().id("id").build() + NamedTransformationGetParams.builder().id("6bZ9x2ZUx").build() } @Test fun pathParams() { - val params = NamedTransformationGetParams.builder().id("id").build() + val params = NamedTransformationGetParams.builder().id("6bZ9x2ZUx").build() - assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(0)).isEqualTo("6bZ9x2ZUx") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt index 5aec18b9..041e16dd 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt @@ -10,8 +10,8 @@ internal class NamedTransformationUpdateParamsTest { @Test fun create() { NamedTransformationUpdateParams.builder() - .id("id") - .enabled(true) + .id("6bZ9x2ZUx") + .enabled(false) .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() @@ -19,9 +19,9 @@ internal class NamedTransformationUpdateParamsTest { @Test fun pathParams() { - val params = NamedTransformationUpdateParams.builder().id("id").build() + val params = NamedTransformationUpdateParams.builder().id("6bZ9x2ZUx").build() - assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(0)).isEqualTo("6bZ9x2ZUx") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } @@ -30,22 +30,22 @@ internal class NamedTransformationUpdateParamsTest { fun body() { val params = NamedTransformationUpdateParams.builder() - .id("id") - .enabled(true) + .id("6bZ9x2ZUx") + .enabled(false) .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() val body = params._body() - assertThat(body.enabled()).contains(true) + assertThat(body.enabled()).contains(false) assertThat(body.name()).contains("small_thumbnail") assertThat(body.transformation()).contains("w-200,h-200,fo-center,cm-resize") } @Test fun bodyWithoutOptionalFields() { - val params = NamedTransformationUpdateParams.builder().id("id").build() + val params = NamedTransformationUpdateParams.builder().id("6bZ9x2ZUx").build() val body = params._body() } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt index d76f3da0..776e46e4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -69,6 +69,7 @@ internal class CustomMetadataFieldServiceAsyncTest { ) .build() ) + .description("description") .build() ) @@ -90,6 +91,7 @@ internal class CustomMetadataFieldServiceAsyncTest { customMetadataFieldServiceAsync.update( CustomMetadataFieldUpdateParams.builder() .id("id") + .description("description") .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt index 200934d1..ff194df0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -46,8 +46,8 @@ internal class NamedTransformationServiceAsyncTest { val namedTransformationFuture = namedTransformationServiceAsync.update( NamedTransformationUpdateParams.builder() - .id("id") - .enabled(true) + .id("6bZ9x2ZUx") + .enabled(false) .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() @@ -83,7 +83,7 @@ internal class NamedTransformationServiceAsyncTest { .build() val namedTransformationServiceAsync = client.namedTransformations() - val namedTransformationFuture = namedTransformationServiceAsync.delete("id") + val namedTransformationFuture = namedTransformationServiceAsync.delete("6bZ9x2ZUx") val namedTransformation = namedTransformationFuture.get() namedTransformation.validate() @@ -99,7 +99,7 @@ internal class NamedTransformationServiceAsyncTest { .build() val namedTransformationServiceAsync = client.namedTransformations() - val namedTransformationFuture = namedTransformationServiceAsync.get("id") + val namedTransformationFuture = namedTransformationServiceAsync.get("6bZ9x2ZUx") val namedTransformation = namedTransformationFuture.get() namedTransformation.validate() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt index 74357e26..6826ee01 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt @@ -69,6 +69,7 @@ internal class CustomMetadataFieldServiceTest { ) .build() ) + .description("description") .build() ) @@ -89,6 +90,7 @@ internal class CustomMetadataFieldServiceTest { customMetadataFieldService.update( CustomMetadataFieldUpdateParams.builder() .id("id") + .description("description") .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt index fcecc2b6..d2a905ff 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -45,8 +45,8 @@ internal class NamedTransformationServiceTest { val namedTransformation = namedTransformationService.update( NamedTransformationUpdateParams.builder() - .id("id") - .enabled(true) + .id("6bZ9x2ZUx") + .enabled(false) .name("small_thumbnail") .transformation("w-200,h-200,fo-center,cm-resize") .build() @@ -80,7 +80,7 @@ internal class NamedTransformationServiceTest { .build() val namedTransformationService = client.namedTransformations() - val namedTransformation = namedTransformationService.delete("id") + val namedTransformation = namedTransformationService.delete("6bZ9x2ZUx") namedTransformation.validate() } @@ -95,7 +95,7 @@ internal class NamedTransformationServiceTest { .build() val namedTransformationService = client.namedTransformations() - val namedTransformation = namedTransformationService.get("id") + val namedTransformation = namedTransformationService.get("6bZ9x2ZUx") namedTransformation.validate() } From 9e89800de54909c560af2f88dee6d618adb205f3 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 13 Aug 2026 09:20:58 +0000 Subject: [PATCH 07/10] Build SDK Stainless-Generated-From: 4facda440d56654b69cf7924942d9533a0f68b1e --- .../io/imagekit/models/NamedTransformation.kt | 34 ++++------ .../NamedTransformationCreateParams.kt | 68 ++++++++----------- .../NamedTransformationUpdateParams.kt | 52 ++++++-------- 3 files changed, 62 insertions(+), 92 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt index 15dc9916..37ebc499 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -62,8 +62,8 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether the named transformation is currently enabled. When this is set to `false`, requests - * using such disabled named transformations fail at delivery time. + * Whether the named transformation is currently enabled. When set to `false`, requests using + * this named transformation fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -71,9 +71,9 @@ private constructor( fun enabled(): Optional = enabled.getOptional("enabled") /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name matching is - * case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is case-sensitive, + * contains only alphanumeric characters or `_` (underscore), and is unique across all named + * transformations for your account. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -81,11 +81,8 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. - * The `tr:` prefix is optional; if present, it is validated. The string must be a valid - * ImageKit transformation and cannot itself reference another named transformation (no - * nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -193,8 +190,8 @@ private constructor( fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** - * Whether the named transformation is currently enabled. When this is set to `false`, - * requests using such disabled named transformations fail at delivery time. + * Whether the named transformation is currently enabled. When set to `false`, requests + * using this named transformation fail at delivery time. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) @@ -207,9 +204,9 @@ private constructor( fun enabled(enabled: JsonField) = apply { this.enabled = enabled } /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is unique + * across all named transformations for your account. */ fun name(name: String) = name(JsonField.of(name)) @@ -222,11 +219,8 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself reference - * another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt index 951a94b5..fda9f4c6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -37,9 +37,9 @@ private constructor( ) : Params { /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name matching is - * case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is case-sensitive, + * contains only alphanumeric characters or `_` (underscore), and is unique across all named + * transformations for your account. * * @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). @@ -47,11 +47,8 @@ private constructor( fun name(): String = body.name() /** - * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. - * The `tr:` prefix is optional; if present, it is validated. The string must be a valid - * ImageKit transformation and cannot itself reference another named transformation (no - * nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). * * @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). @@ -59,8 +56,8 @@ private constructor( fun transformation(): String = body.transformation() /** - * Whether the named transformation is currently enabled. When this is set to `false`, requests - * using such disabled named transformations fail at delivery time. + * Whether the named transformation is currently enabled. When set to `false`, requests using + * this named transformation fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -141,9 +138,9 @@ private constructor( fun body(body: Body) = apply { this.body = body.toBuilder() } /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is unique + * across all named transformations for your account. */ fun name(name: String) = apply { body.name(name) } @@ -156,11 +153,8 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself reference - * another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -176,8 +170,8 @@ private constructor( } /** - * Whether the named transformation is currently enabled. When this is set to `false`, - * requests using such disabled named transformations fail at delivery time. + * Whether the named transformation is currently enabled. When set to `false`, requests + * using this named transformation fail at delivery time. */ fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } @@ -352,9 +346,9 @@ private constructor( ) : this(name, transformation, enabled, mutableMapOf()) /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is unique + * across all named transformations for your account. * * @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). @@ -362,11 +356,8 @@ private constructor( fun name(): String = name.getRequired("name") /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself reference - * another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). * * @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). @@ -374,8 +365,8 @@ private constructor( fun transformation(): String = transformation.getRequired("transformation") /** - * Whether the named transformation is currently enabled. When this is set to `false`, - * requests using such disabled named transformations fail at delivery time. + * Whether the named transformation is currently enabled. When set to `false`, requests + * using this named transformation fail at delivery time. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -449,9 +440,9 @@ private constructor( } /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is + * unique across all named transformations for your account. */ fun name(name: String) = name(JsonField.of(name)) @@ -465,11 +456,8 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself - * reference another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) @@ -486,8 +474,8 @@ private constructor( } /** - * Whether the named transformation is currently enabled. When this is set to `false`, - * requests using such disabled named transformations fail at delivery time. + * Whether the named transformation is currently enabled. When set to `false`, requests + * using this named transformation fail at delivery time. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt index 94b67e4b..ff9ae3fa 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -48,9 +48,9 @@ private constructor( fun enabled(): Optional = body.enabled() /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name matching is - * case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is case-sensitive, + * contains only alphanumeric characters or `_` (underscore), and is unique across all named + * transformations for your account. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -58,11 +58,8 @@ private constructor( fun name(): Optional = body.name() /** - * The transformation string this name refers to, for example `w-150,h-150,fo-center,cm-resize`. - * The `tr:` prefix is optional; if present, it is validated. The string must be a valid - * ImageKit transformation and cannot itself reference another named transformation (no - * nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -160,9 +157,9 @@ private constructor( fun enabled(enabled: JsonField) = apply { body.enabled(enabled) } /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is unique + * across all named transformations for your account. */ fun name(name: String) = apply { body.name(name) } @@ -175,11 +172,8 @@ private constructor( fun name(name: JsonField) = apply { body.name(name) } /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself reference - * another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = apply { body.transformation(transformation) } @@ -364,9 +358,9 @@ private constructor( fun enabled(): Optional = enabled.getOptional("enabled") /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is unique + * across all named transformations for your account. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -374,11 +368,8 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself reference - * another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -459,9 +450,9 @@ private constructor( fun enabled(enabled: JsonField) = apply { this.enabled = enabled } /** - * Alias for the transformation string, used in URLs as `tr:n-`. Must contain only - * alphanumeric characters or `_` (no hyphens), and be unique for your account. Name - * matching is case-sensitive. + * Alias for the transformation string, used in URLs as `tr:n-`. This is + * case-sensitive, contains only alphanumeric characters or `_` (underscore), and is + * unique across all named transformations for your account. */ fun name(name: String) = name(JsonField.of(name)) @@ -475,11 +466,8 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * The transformation string this name refers to, for example - * `w-150,h-150,fo-center,cm-resize`. The `tr:` prefix is optional; if present, it is - * validated. The string must be a valid ImageKit transformation and cannot itself - * reference another named transformation (no nesting). Learn more about the - * [transformation syntax](https://imagekit.io/docs/transformations). + * The transformation string this named transformation refers to. Learn more about the + * [transformation string syntax](https://imagekit.io/docs/transformations). */ fun transformation(transformation: String) = transformation(JsonField.of(transformation)) From e305f6e59449661d16956b1a7a3426f3877ccb61 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 13 Aug 2026 11:18:59 +0000 Subject: [PATCH 08/10] Build SDK Stainless-Generated-From: 072be6b0929b3e5bdf98c34fcdfa1a43efb38fba --- .../NamedTransformationDeleteResponse.kt | 129 ------------------ .../async/NamedTransformationServiceAsync.kt | 42 ++---- .../NamedTransformationServiceAsyncImpl.kt | 19 +-- .../blocking/NamedTransformationService.kt | 36 ++--- .../NamedTransformationServiceImpl.kt | 23 +--- .../NamedTransformationDeleteResponseTest.kt | 31 ----- .../NamedTransformationServiceAsyncTest.kt | 5 +- .../NamedTransformationServiceTest.kt | 4 +- 8 files changed, 43 insertions(+), 246 deletions(-) delete mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt delete mode 100644 image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt deleted file mode 100644 index 03229d36..00000000 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponse.kt +++ /dev/null @@ -1,129 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package io.imagekit.models.namedtransformations - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.core.ExcludeMissing -import io.imagekit.core.JsonValue -import io.imagekit.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects - -class NamedTransformationDeleteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor(private val additionalProperties: MutableMap) { - - @JsonCreator private constructor() : this(mutableMapOf()) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NamedTransformationDeleteResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NamedTransformationDeleteResponse]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(namedTransformationDeleteResponse: NamedTransformationDeleteResponse) = - apply { - additionalProperties = - namedTransformationDeleteResponse.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NamedTransformationDeleteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): NamedTransformationDeleteResponse = - NamedTransformationDeleteResponse(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(): NamedTransformationDeleteResponse = apply { - if (validated) { - return@apply - } - - 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 = 0 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NamedTransformationDeleteResponse && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NamedTransformationDeleteResponse{additionalProperties=$additionalProperties}" -} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt index b6eb3bf5..6a6cd3d3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -4,11 +4,11 @@ package io.imagekit.services.async import io.imagekit.core.ClientOptions import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponse import io.imagekit.core.http.HttpResponseFor import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams -import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -115,7 +115,7 @@ interface NamedTransformationServiceAsync { * is best-effort and can't detect references in your own application code or in previously * generated URLs. */ - fun delete(id: String): CompletableFuture = + fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ @@ -123,32 +123,26 @@ interface NamedTransformationServiceAsync { id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): CompletableFuture = - delete(id, params, RequestOptions.none()) + ): CompletableFuture = delete(id, params, RequestOptions.none()) /** @see delete */ fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see delete */ - fun delete( - params: NamedTransformationDeleteParams - ): CompletableFuture = delete(params, RequestOptions.none()) + fun delete(params: NamedTransformationDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) /** @see delete */ - fun delete( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture = + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** Retrieves the named transformation identified by `id`. */ @@ -283,9 +277,7 @@ interface NamedTransformationServiceAsync { * Returns a raw HTTP response for `delete /v1/named-transformations/{id}`, but is otherwise * the same as [NamedTransformationServiceAsync.delete]. */ - fun delete( - id: String - ): CompletableFuture> = + fun delete(id: String): CompletableFuture = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ @@ -293,33 +285,27 @@ interface NamedTransformationServiceAsync { id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): CompletableFuture> = - delete(id, params, RequestOptions.none()) + ): CompletableFuture = delete(id, params, RequestOptions.none()) /** @see delete */ fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture /** @see delete */ - fun delete( - params: NamedTransformationDeleteParams - ): CompletableFuture> = + fun delete(params: NamedTransformationDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) /** @see delete */ - fun delete( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture> = + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt index 396ff03e..dec90a74 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package io.imagekit.services.async import io.imagekit.core.ClientOptions import io.imagekit.core.RequestOptions import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.emptyHandler import io.imagekit.core.handlers.errorBodyHandler import io.imagekit.core.handlers.errorHandler import io.imagekit.core.handlers.jsonHandler @@ -19,7 +20,6 @@ import io.imagekit.core.prepareAsync import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams -import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -68,9 +68,9 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // delete /v1/named-transformations/{id} - withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + withRawResponse().delete(params, requestOptions).thenAccept {} override fun get( params: NamedTransformationGetParams, @@ -187,13 +187,12 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -210,13 +209,7 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + response.use { deleteHandler.handle(it) } } } } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt index c647d3b1..f0f8bcc0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -5,11 +5,11 @@ package io.imagekit.services.blocking import com.google.errorprone.annotations.MustBeClosed import io.imagekit.core.ClientOptions import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponse import io.imagekit.core.http.HttpResponseFor import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams -import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -112,34 +112,32 @@ interface NamedTransformationService { * is best-effort and can't detect references in your own application code or in previously * generated URLs. */ - fun delete(id: String): NamedTransformationDeleteResponse = - delete(id, NamedTransformationDeleteParams.none()) + fun delete(id: String) = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): NamedTransformationDeleteResponse = delete(params.toBuilder().id(id).build(), requestOptions) + ) = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): NamedTransformationDeleteResponse = delete(id, params, RequestOptions.none()) + ) = delete(id, params, RequestOptions.none()) /** @see delete */ fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): NamedTransformationDeleteResponse + ) /** @see delete */ - fun delete(params: NamedTransformationDeleteParams): NamedTransformationDeleteResponse = - delete(params, RequestOptions.none()) + fun delete(params: NamedTransformationDeleteParams) = delete(params, RequestOptions.none()) /** @see delete */ - fun delete(id: String, requestOptions: RequestOptions): NamedTransformationDeleteResponse = + fun delete(id: String, requestOptions: RequestOptions) = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** Retrieves the named transformation identified by `id`. */ @@ -277,8 +275,7 @@ interface NamedTransformationService { * the same as [NamedTransformationService.delete]. */ @MustBeClosed - fun delete(id: String): HttpResponseFor = - delete(id, NamedTransformationDeleteParams.none()) + fun delete(id: String): HttpResponse = delete(id, NamedTransformationDeleteParams.none()) /** @see delete */ @MustBeClosed @@ -286,37 +283,30 @@ interface NamedTransformationService { id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - delete(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) /** @see delete */ @MustBeClosed fun delete( id: String, params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), - ): HttpResponseFor = - delete(id, params, RequestOptions.none()) + ): HttpResponse = delete(id, params, RequestOptions.none()) /** @see delete */ @MustBeClosed fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponse /** @see delete */ @MustBeClosed - fun delete( - params: NamedTransformationDeleteParams - ): HttpResponseFor = + fun delete(params: NamedTransformationDeleteParams): HttpResponse = delete(params, RequestOptions.none()) /** @see delete */ @MustBeClosed - fun delete( - id: String, - requestOptions: RequestOptions, - ): HttpResponseFor = + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = delete(id, NamedTransformationDeleteParams.none(), requestOptions) /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt index 68040f2c..137e6c62 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt @@ -5,6 +5,7 @@ package io.imagekit.services.blocking import io.imagekit.core.ClientOptions import io.imagekit.core.RequestOptions import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.emptyHandler import io.imagekit.core.handlers.errorBodyHandler import io.imagekit.core.handlers.errorHandler import io.imagekit.core.handlers.jsonHandler @@ -19,7 +20,6 @@ import io.imagekit.core.prepare import io.imagekit.models.NamedTransformation import io.imagekit.models.namedtransformations.NamedTransformationCreateParams import io.imagekit.models.namedtransformations.NamedTransformationDeleteParams -import io.imagekit.models.namedtransformations.NamedTransformationDeleteResponse import io.imagekit.models.namedtransformations.NamedTransformationGetParams import io.imagekit.models.namedtransformations.NamedTransformationListParams import io.imagekit.models.namedtransformations.NamedTransformationUpdateParams @@ -61,12 +61,10 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma // get /v1/named-transformations withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: NamedTransformationDeleteParams, - requestOptions: RequestOptions, - ): NamedTransformationDeleteResponse = + override fun delete(params: NamedTransformationDeleteParams, requestOptions: RequestOptions) { // delete /v1/named-transformations/{id} - withRawResponse().delete(params, requestOptions).parse() + withRawResponse().delete(params, requestOptions) + } override fun get( params: NamedTransformationGetParams, @@ -174,13 +172,12 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val deleteHandler: Handler = emptyHandler() override fun delete( params: NamedTransformationDeleteParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponse { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -195,13 +192,7 @@ internal constructor(private val clientOptions: ClientOptions) : NamedTransforma val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + response.use { deleteHandler.handle(it) } } } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt deleted file mode 100644 index fa89a927..00000000 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteResponseTest.kt +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package io.imagekit.models.namedtransformations - -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 NamedTransformationDeleteResponseTest { - - @Test - fun create() { - val namedTransformationDeleteResponse = NamedTransformationDeleteResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val namedTransformationDeleteResponse = NamedTransformationDeleteResponse.builder().build() - - val roundtrippedNamedTransformationDeleteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(namedTransformationDeleteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNamedTransformationDeleteResponse) - .isEqualTo(namedTransformationDeleteResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt index ff194df0..ffcecd17 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -83,10 +83,9 @@ internal class NamedTransformationServiceAsyncTest { .build() val namedTransformationServiceAsync = client.namedTransformations() - val namedTransformationFuture = namedTransformationServiceAsync.delete("6bZ9x2ZUx") + val future = namedTransformationServiceAsync.delete("6bZ9x2ZUx") - val namedTransformation = namedTransformationFuture.get() - namedTransformation.validate() + val response = future.get() } @Disabled("Mock server tests are disabled") diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt index d2a905ff..054d5fa0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -80,9 +80,7 @@ internal class NamedTransformationServiceTest { .build() val namedTransformationService = client.namedTransformations() - val namedTransformation = namedTransformationService.delete("6bZ9x2ZUx") - - namedTransformation.validate() + namedTransformationService.delete("6bZ9x2ZUx") } @Disabled("Mock server tests are disabled") From 90797799cc7fe9f4b0e4580b0e47e38aaad30dfe Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 14 Aug 2026 07:39:57 +0000 Subject: [PATCH 09/10] Build SDK Stainless-Generated-From: 87e010212e4fed1814dbd0fee034cc68af7ee4fb --- .../io/imagekit/models/NamedTransformationTest.kt | 7 ++++--- .../NamedTransformationCreateParamsTest.kt | 10 +++++----- .../NamedTransformationUpdateParamsTest.kt | 6 +++--- .../async/NamedTransformationServiceAsyncTest.kt | 4 ++-- .../blocking/NamedTransformationServiceTest.kt | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt index ea9fcc65..de6b917f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt @@ -18,7 +18,7 @@ internal class NamedTransformationTest { .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) .enabled(true) .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .build() assertThat(namedTransformation.id()).contains("6bZ9x2ZUx") @@ -26,7 +26,8 @@ internal class NamedTransformationTest { .contains(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) assertThat(namedTransformation.enabled()).contains(true) assertThat(namedTransformation.name()).contains("small_thumbnail") - assertThat(namedTransformation.transformation()).contains("w-150,h-150,fo-center,cm-resize") + assertThat(namedTransformation.transformation()) + .contains("w-150,h-150,fo-center,cm-pad_resize") } @Test @@ -38,7 +39,7 @@ internal class NamedTransformationTest { .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) .enabled(true) .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .build() val roundtrippedNamedTransformation = diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt index 1adeab2d..d5662a96 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt @@ -11,7 +11,7 @@ internal class NamedTransformationCreateParamsTest { fun create() { NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .enabled(true) .build() } @@ -21,14 +21,14 @@ internal class NamedTransformationCreateParamsTest { val params = NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .enabled(true) .build() val body = params._body() assertThat(body.name()).isEqualTo("small_thumbnail") - assertThat(body.transformation()).isEqualTo("w-150,h-150,fo-center,cm-resize") + assertThat(body.transformation()).isEqualTo("w-150,h-150,fo-center,cm-pad_resize") assertThat(body.enabled()).contains(true) } @@ -37,12 +37,12 @@ internal class NamedTransformationCreateParamsTest { val params = NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .build() val body = params._body() assertThat(body.name()).isEqualTo("small_thumbnail") - assertThat(body.transformation()).isEqualTo("w-150,h-150,fo-center,cm-resize") + assertThat(body.transformation()).isEqualTo("w-150,h-150,fo-center,cm-pad_resize") } } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt index 041e16dd..533c1699 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParamsTest.kt @@ -13,7 +13,7 @@ internal class NamedTransformationUpdateParamsTest { .id("6bZ9x2ZUx") .enabled(false) .name("small_thumbnail") - .transformation("w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-pad_resize") .build() } @@ -33,14 +33,14 @@ internal class NamedTransformationUpdateParamsTest { .id("6bZ9x2ZUx") .enabled(false) .name("small_thumbnail") - .transformation("w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-pad_resize") .build() val body = params._body() assertThat(body.enabled()).contains(false) assertThat(body.name()).contains("small_thumbnail") - assertThat(body.transformation()).contains("w-200,h-200,fo-center,cm-resize") + assertThat(body.transformation()).contains("w-200,h-200,fo-center,cm-pad_resize") } @Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt index ffcecd17..a8740f05 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -24,7 +24,7 @@ internal class NamedTransformationServiceAsyncTest { namedTransformationServiceAsync.create( NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .enabled(true) .build() ) @@ -49,7 +49,7 @@ internal class NamedTransformationServiceAsyncTest { .id("6bZ9x2ZUx") .enabled(false) .name("small_thumbnail") - .transformation("w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-pad_resize") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt index 054d5fa0..6b813d2f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -24,7 +24,7 @@ internal class NamedTransformationServiceTest { namedTransformationService.create( NamedTransformationCreateParams.builder() .name("small_thumbnail") - .transformation("w-150,h-150,fo-center,cm-resize") + .transformation("w-150,h-150,fo-center,cm-pad_resize") .enabled(true) .build() ) @@ -48,7 +48,7 @@ internal class NamedTransformationServiceTest { .id("6bZ9x2ZUx") .enabled(false) .name("small_thumbnail") - .transformation("w-200,h-200,fo-center,cm-resize") + .transformation("w-200,h-200,fo-center,cm-pad_resize") .build() ) From 396aeeaf53f1ef434662a887d57c58763f068bfd Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Sat, 15 Aug 2026 09:38:43 +0000 Subject: [PATCH 10/10] Build SDK Stainless-Generated-From: 95b7a149f19b209bada580ae91c3da0ff4a5cab7 --- .../io/imagekit/models/NamedTransformation.kt | 76 ++++++++++++------- .../models/NamedTransformationTest.kt | 10 +-- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt index 37ebc499..a6701872 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -10,11 +10,11 @@ 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.time.OffsetDateTime import java.util.Collections import java.util.Objects -import java.util.Optional /** * A named transformation is an alias for a transformation string, letting you apply and later @@ -48,46 +48,46 @@ private constructor( /** * Unique identifier for a named transformation. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * ISO 8601 timestamp of when the named transformation was created. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 createdAt(): Optional = createdAt.getOptional("createdAt") + fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** * Whether the named transformation is currently enabled. When set to `false`, requests using * this named transformation fail at delivery time. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 enabled(): Optional = enabled.getOptional("enabled") + fun enabled(): Boolean = enabled.getRequired("enabled") /** * Alias for the transformation string, used in URLs as `tr:n-`. This is case-sensitive, * contains only alphanumeric characters or `_` (underscore), and is unique across all named * transformations for your account. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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(): Optional = name.getOptional("name") + fun name(): String = name.getRequired("name") /** * The transformation string this named transformation refers to. Learn more about the * [transformation string syntax](https://imagekit.io/docs/transformations). * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 transformation(): Optional = transformation.getOptional("transformation") + fun transformation(): String = transformation.getRequired("transformation") /** * Returns the raw JSON value of [id]. @@ -142,18 +142,29 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [NamedTransformation]. */ + /** + * Returns a mutable builder for constructing an instance of [NamedTransformation]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .enabled() + * .name() + * .transformation() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [NamedTransformation]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var enabled: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var transformation: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var enabled: JsonField? = null + private var name: JsonField? = null + private var transformation: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -258,14 +269,25 @@ private constructor( * Returns an immutable instance of [NamedTransformation]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .enabled() + * .name() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): NamedTransformation = NamedTransformation( - id, - createdAt, - enabled, - name, - transformation, + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("enabled", enabled), + checkRequired("name", name), + checkRequired("transformation", transformation), additionalProperties.toMutableMap(), ) } diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt index de6b917f..32552d9b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/NamedTransformationTest.kt @@ -21,13 +21,13 @@ internal class NamedTransformationTest { .transformation("w-150,h-150,fo-center,cm-pad_resize") .build() - assertThat(namedTransformation.id()).contains("6bZ9x2ZUx") + assertThat(namedTransformation.id()).isEqualTo("6bZ9x2ZUx") assertThat(namedTransformation.createdAt()) - .contains(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) - assertThat(namedTransformation.enabled()).contains(true) - assertThat(namedTransformation.name()).contains("small_thumbnail") + .isEqualTo(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) + assertThat(namedTransformation.enabled()).isEqualTo(true) + assertThat(namedTransformation.name()).isEqualTo("small_thumbnail") assertThat(namedTransformation.transformation()) - .contains("w-150,h-150,fo-center,cm-pad_resize") + .isEqualTo("w-150,h-150,fo-center,cm-pad_resize") } @Test