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..a6701872 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/NamedTransformation.kt @@ -0,0 +1,361 @@ +// 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.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +/** + * 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 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val enabled: 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("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(id, createdAt, enabled, name, transformation, mutableMapOf()) + + /** + * Unique identifier for a named transformation. + * + * @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(): String = id.getRequired("id") + + /** + * ISO 8601 timestamp of when the named transformation was created. + * + * @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(): 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 or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + 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 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 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). + */ + fun transformation(): String = transformation.getRequired("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 [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [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]. + * + * 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? = 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 + internal fun from(namedTransformation: NamedTransformation) = apply { + id = namedTransformation.id + createdAt = namedTransformation.createdAt + enabled = namedTransformation.enabled + name = namedTransformation.name + transformation = namedTransformation.transformation + additionalProperties = namedTransformation.additionalProperties.toMutableMap() + } + + /** Unique identifier for a 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 } + + /** ISO 8601 timestamp of 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 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)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** + * 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)) + + /** + * 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 named transformation refers to. Learn more about the + * [transformation string 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 + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .enabled() + * .name() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NamedTransformation = + NamedTransformation( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("enabled", enabled), + checkRequired("name", name), + checkRequired("transformation", 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() + enabled() + 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 (enabled.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 && + enabled == other.enabled && + name == other.name && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, enabled, name, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "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/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 new file mode 100644 index 00000000..fda9f4c6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParams.kt @@ -0,0 +1,611 @@ +// 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. + * + * 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). + * + * You can create up to 250 named transformations per account. + */ +class NamedTransformationCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * 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). + */ + fun name(): String = body.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 or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformation(): String = body.transformation() + + /** + * 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). + */ + fun enabled(): Optional = body.enabled() + + /** + * 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 [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _enabled(): JsonField = body._enabled() + + 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] + * - [enabled] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * 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) } + + /** + * 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 named transformation refers to. Learn more about the + * [transformation string 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 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) } + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun enabled(enabled: JsonField) = apply { body.enabled(enabled) } + + 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 enabled: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + ) : this(name, transformation, enabled, mutableMapOf()) + + /** + * 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). + */ + 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 or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformation(): String = transformation.getRequired("transformation") + + /** + * 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). + */ + fun enabled(): Optional = enabled.getOptional("enabled") + + /** + * 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 [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 enabled: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + transformation = body.transformation + enabled = body.enabled + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * 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)) + + /** + * 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 named transformation refers to. Learn more about the + * [transformation string 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 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)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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), + enabled, + 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() + enabled() + 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 (enabled.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 && + enabled == other.enabled && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, transformation, enabled, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, transformation=$transformation, enabled=$enabled, 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..3e7b9cbb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationDeleteParams.kt @@ -0,0 +1,244 @@ +// 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`. + * + * 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. + */ +class NamedTransformationDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + 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. */ + 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() + } + + /** Unique identifier for a named transformation. */ + 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..3069e5af --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParams.kt @@ -0,0 +1,197 @@ +// 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 { + + /** Unique identifier for a named transformation. */ + 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() + } + + /** Unique identifier for a named transformation. */ + 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..ff9ae3fa --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/namedtransformations/NamedTransformationUpdateParams.kt @@ -0,0 +1,594 @@ +// 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; 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 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( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Unique identifier for a named transformation. */ + fun id(): Optional = Optional.ofNullable(id) + + /** + * 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). + */ + fun enabled(): Optional = body.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). + */ + fun name(): Optional = body.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). + */ + fun transformation(): Optional = body.transformation() + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _enabled(): JsonField = body._enabled() + + /** + * 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() + } + + /** Unique identifier for a named transformation. */ + 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: + * - [enabled] + * - [name] + * - [transformation] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Whether the named transformation is enabled. Omit to leave the current value unchanged. + */ + fun enabled(enabled: Boolean) = apply { body.enabled(enabled) } + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun enabled(enabled: JsonField) = apply { body.enabled(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. + */ + 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 named transformation refers to. Learn more about the + * [transformation string 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) + } + + 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 enabled: JsonField, + private val name: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(enabled, name, transformation, mutableMapOf()) + + /** + * 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). + */ + fun enabled(): Optional = enabled.getOptional("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). + */ + fun name(): Optional = name.getOptional("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). + */ + fun transformation(): Optional = transformation.getOptional("transformation") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [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 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 { + enabled = body.enabled + name = body.name + transformation = body.transformation + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Whether the named transformation is enabled. Omit to leave the current value + * unchanged. + */ + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** + * 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)) + + /** + * 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 named transformation refers to. Learn more about the + * [transformation string 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 + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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(enabled, 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 + } + + enabled() + 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 (enabled.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 && + enabled == other.enabled && + name == other.name && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(enabled, name, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{enabled=$enabled, 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/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 new file mode 100644 index 00000000..6a6cd3d3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsync.kt @@ -0,0 +1,352 @@ +// 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.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.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. + * + * 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). + * + * You can create up to 250 named transformations per account. + */ + 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; 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 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()) + + /** @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`. + * + * 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 = + 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..dec90a74 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncImpl.kt @@ -0,0 +1,250 @@ +// 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.emptyHandler +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).thenAccept {} + + 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 = emptyHandler() + + 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) } + } + } + } + + 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/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 new file mode 100644 index 00000000..f0f8bcc0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationService.kt @@ -0,0 +1,353 @@ +// 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.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.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. + * + * 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). + * + * You can create up to 250 named transformations per account. + */ + 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; 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 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()) + + /** @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`. + * + * 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) = delete(id, NamedTransformationDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + ) = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: NamedTransformationDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + 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): HttpResponse = delete(id, NamedTransformationDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: NamedTransformationDeleteParams = NamedTransformationDeleteParams.none(), + ): HttpResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: NamedTransformationDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + 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..137e6c62 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/NamedTransformationServiceImpl.kt @@ -0,0 +1,229 @@ +// 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.emptyHandler +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) { + // delete /v1/named-transformations/{id} + withRawResponse().delete(params, requestOptions) + } + + 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 = emptyHandler() + + override fun delete( + params: NamedTransformationDeleteParams, + requestOptions: RequestOptions, + ): 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()) + 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) } + } + } + + 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..32552d9b --- /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")) + .enabled(true) + .name("small_thumbnail") + .transformation("w-150,h-150,fo-center,cm-pad_resize") + .build() + + assertThat(namedTransformation.id()).isEqualTo("6bZ9x2ZUx") + assertThat(namedTransformation.createdAt()) + .isEqualTo(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) + assertThat(namedTransformation.enabled()).isEqualTo(true) + assertThat(namedTransformation.name()).isEqualTo("small_thumbnail") + assertThat(namedTransformation.transformation()) + .isEqualTo("w-150,h-150,fo-center,cm-pad_resize") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val namedTransformation = + NamedTransformation.builder() + .id("6bZ9x2ZUx") + .createdAt(OffsetDateTime.parse("2024-01-10T09:00:00.000Z")) + .enabled(true) + .name("small_thumbnail") + .transformation("w-150,h-150,fo-center,cm-pad_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/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/NamedTransformationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationCreateParamsTest.kt new file mode 100644 index 00000000..d5662a96 --- /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("w-150,h-150,fo-center,cm-pad_resize") + .enabled(true) + .build() + } + + @Test + fun body() { + val params = + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .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-pad_resize") + assertThat(body.enabled()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + NamedTransformationCreateParams.builder() + .name("small_thumbnail") + .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-pad_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..035befdc --- /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("6bZ9x2ZUx").build() + } + + @Test + fun pathParams() { + val params = NamedTransformationDeleteParams.builder().id("6bZ9x2ZUx").build() + + 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/NamedTransformationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/namedtransformations/NamedTransformationGetParamsTest.kt new file mode 100644 index 00000000..1b7ba85f --- /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("6bZ9x2ZUx").build() + } + + @Test + fun pathParams() { + val params = NamedTransformationGetParams.builder().id("6bZ9x2ZUx").build() + + 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/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..533c1699 --- /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("6bZ9x2ZUx") + .enabled(false) + .name("small_thumbnail") + .transformation("w-200,h-200,fo-center,cm-pad_resize") + .build() + } + + @Test + fun pathParams() { + val params = NamedTransformationUpdateParams.builder().id("6bZ9x2ZUx").build() + + assertThat(params._pathParam(0)).isEqualTo("6bZ9x2ZUx") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + NamedTransformationUpdateParams.builder() + .id("6bZ9x2ZUx") + .enabled(false) + .name("small_thumbnail") + .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-pad_resize") + } + + @Test + fun bodyWithoutOptionalFields() { + 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 new file mode 100644 index 00000000..a8740f05 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/NamedTransformationServiceAsyncTest.kt @@ -0,0 +1,106 @@ +// 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("w-150,h-150,fo-center,cm-pad_resize") + .enabled(true) + .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("6bZ9x2ZUx") + .enabled(false) + .name("small_thumbnail") + .transformation("w-200,h-200,fo-center,cm-pad_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 future = namedTransformationServiceAsync.delete("6bZ9x2ZUx") + + val response = future.get() + } + + @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("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 new file mode 100644 index 00000000..6b813d2f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/NamedTransformationServiceTest.kt @@ -0,0 +1,100 @@ +// 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("w-150,h-150,fo-center,cm-pad_resize") + .enabled(true) + .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("6bZ9x2ZUx") + .enabled(false) + .name("small_thumbnail") + .transformation("w-200,h-200,fo-center,cm-pad_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() + + namedTransformationService.delete("6bZ9x2ZUx") + } + + @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("6bZ9x2ZUx") + + 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()